我想每10秒为结果请求这个AJAX响应
function show() {
var ele = document.getElementById("ping");
if (ele.style.display == "none") {
ele.style.display = "block";
}
jQuery.ajax({
type: "POST",
url: "checkit.php",
cache: false,
success: function (response) {
if (response == 1) {
alert("Success");
}
}
});
}
答案 0 :(得分:-1)
你需要一个定时循环。
function show() {
var ele = document.getElementById("ping");
if (ele.style.display == "none") {
ele.style.display = "block";
}
window.setInterval(function(){ //loop
jQuery.ajax({
type: "POST",
url: "checkit.php",
cache: false,
success: function (response) {
if (response == 1) {
alert("Success");
}
}
});
}, 10000); //10000 = 10 seconds
}