方法一:
$.when($.ajax({url: ‘url_1‘,data: data, success: function() {
console.log(‘aaaa‘);
}}),$.ajax({url: ‘url_2‘, data: data, success: function(){
console.log(‘bbb‘)
}})).done(function(){
console.log(‘ccccc‘);
}).fail(function(){
console.log(‘fialed‘);
})
方法二:
var num = 0;
$.ajax({
url: ‘url1‘,
success: function (){
num++;
console.log(‘aaa‘);
if(num==2){
console.log(‘ccc‘);
}
}
});
$.ajax({
url: ‘url2‘,
success: function (){
num++;
console.log(‘bbb‘);
if(num==2){
console.log(‘ccc‘);
}
}
});
时间: 2024-09-26 20:09:30