我有一个接口,需要在三个接口都调用成功之后执行,不知道怎么写
如用了jQuery 1.6+,可以用jQuery延迟函数
$.when($.get('/a'),$.get('/b'),$.get('/c')).then(function(a,b,c){
return $.get('/d',{a:a,b:b,c:c})
}).then(function(d){
console.log(d)
})
如果不考虑兼容或已引用polyfill,则建议用Promise
// ajax_X 是一个返回promise对像的函数,jQuery 延迟对像也是可以的
Promise.all([ajax_a(),ajax_b(),ajax_c()])
.then(([a,b,c])=>ajax_d({a,b,c}))
.then(d=>console.log(d))
用promise呀