在所有AJAX请求完成后采取的措施 [英] action after all of AJAX request finish
本文介绍了在所有AJAX请求完成后采取的措施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在ajax之后执行操作,但是我不能
I trying to execute an action after the ajax, but I can't
$.each(LinkUnique,function(i){
$.ajax({
type: "POST",
url: 'http://xxxx.net/',
success: function(msg){
if(msg.indexOf("http://") !=-1)
link = link+msg+"\n";
}
});
});
在脚本之后执行下一个操作:
Here the next action after the script:
alert("Finish");
async: false
不是一个好的选择,因为我的页面完全停止了.
async: false
isn't a good option because my page stops completely.
推荐答案
您可能正在尝试等待所有ajax调用完成,因为您正在执行多个操作:
You're probably trying to wait until all the ajax calls have completed, as you're doing multiple :
var xhrs = [],
link = '';
$.each(LinkUnique,function(i){
var xhr = $.ajax({
type: 'POST',
url : 'http://xxxx.net/'
}).done(function(msg) {
if(msg.indexOf("http://") !=-1)
link = link+msg+"\n";
});
xhrs.push(xhr);
});
$.when.apply($, xhrs).then(function() {
alert(link);
});
这篇关于在所有AJAX请求完成后采取的措施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文