码迷,mamicode.com
首页 > 其他好文 > 详细

setInterval 启用和停止,见代码

时间:2015-05-30 12:08:44      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

 <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, 3000);

            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 启用和停止,见代码

标签:

原文地址:http://www.cnblogs.com/love540376/p/4540090.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!