js setInterval 启用&停止
以下面例子为说明:
<title></title> <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script> <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var iCount = setInterval(GetBack, ); function GetBack() { alert("aa"); $.ajax({ type: "POST", url: "WebForm4.aspx/GetString", dataType: "text", contentType: "application/json; charset=utf-8", beforeSend: function (XMLHttpRequest) { }, success: function (msg) { alert("ff"); }, error: function (msg) { alert(msg); } }); } $("#cOk").click(function (e) { clearInterval(iCount); }); }); </script> <div> <a href="#" id="cOk" >sss</a> </div> 后台代码 ------------------ [WebMethod] public static string GetString() { return "aa"; }
总结:启用使用 setInterval(function(){}, timer);
停止使用 clearInterval(启用的interval元素)。
相关推荐
88274956 2020-11-03
runner 2020-09-01
梦的天空 2020-08-25
移动开发与培训 2020-08-16
ReunionIsland 2020-08-16
lyqdanang 2020-08-16
MyNameIsXiaoLai 2020-07-08
星辰的笔记 2020-07-04
csstpeixun 2020-06-28
letheashura 2020-06-26
liaoxuewu 2020-06-26
sunzhihaofuture 2020-06-21
FEvivi 2020-06-16
坚持着执着 2020-06-16
waterv 2020-06-14
xiaoge00 2020-06-14
firejq 2020-06-14
firstboy0 2020-06-14
e度空间 2020-06-12
zhongweinan 2020-06-10