0
我一直在工作的ajax调用,需要重复调用,直到我得到一个响应。示例场景是,“管理员”发布内容时会通知“用户”。连续的Ajax调用,直到满足预期的响应
我做了这样的事情,但效果不好。
function posts() {
$.ajax
({
type: "GET",
url: "http://mywebsite.csit.ph/process/new_posts.php",
data: "user="+user,
success: function(){
if(data){ //if new_posts.php echo something.
//do task here
}else{
posts(); //calling the ajax again.
}
},
error: function(){
posts(); //calling the ajax again.
}
});
}
posts()函数需要被调用,直到收到响应为止。
使用while循环后端的答复..和AJAX调用一次 –
@chiragsatapara尝试,而在我的PHP的答复,使1个Ajax调用你的建议,但还是没有与数据的成功状态去 –