jsp页面的js定时器的实现和关闭(不跳转页面)

来源:互联网 发布:cf出现网络异常断开 编辑:程序博客网 时间:2024/06/04 23:25
直接线上代码
<script type="text/javascript">var timename=null;function show1(){timename=setInterval(function cj(){$.ajax({        type: "GET",        url: "/opsmanager/server/diary",        success:function(json){        console.log(json);        $("#textareaid").val(json);        }, error:function(){clearInterval(timename);         }   });},100);}function show2(){clearInterval(timename);}</script></head><body><div style="padding:15px 25px;width:1200px;height: 830px;background-color: white;"><form><input type="button" onclick="show1()" value="查询"><input type="button" onclick="show2()" value="停止"><fieldset><legend>配置文件修改</legend><div style="float: left;"><textarea rows="20" cols="100" name="textareaid" id="textareaid"></textarea></div></fieldset></form>
设置一个按钮进行开启和关闭定时器
timename=setInterval(function a(){},1000)前面的a是定时的要执行的程序,后面的1000是多久执行一次,show2()是停止ding
时器
0 0
原创粉丝点击