标题: jq循环请求后端
时间: 2020-11-21
<html>
<head>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
$(function() {
function test(){
$(".test").append("|->");
/*
$.ajax({
url:"/123.php",
type:"get",
timeout:"15000",
async:true,
success:function(data){
$(".test").append(data);
}
})
*/
}
$(".star").click(function(){
num = $('.num').val();
timer = setInterval(function() {
test();
if (num){
num--;
if (num <= 0) clearInterval(timer);
}
}, 1000);
})
$(".stop").click(function(){
clearInterval(timer);
})
})
</script>
</head>
<body>
<input type="text" class="num" size="5">
<button class="star">开始</button><button class="stop">停止</button>
<div class="test"></div>
</body>
</html>
『回复列表(2|隐藏机器人聊天)』