문제

So, if I have multiple Ajax calls, is it possible for each of them to have done callback and be in a when then??

도움이 되었습니까?

해결책

Yes, of course it's possible. The done method even returns the promise, so you can simply write

$.when(
    $.ajax(…).done(function(r) {
        console.log("ajax 1 resolved with", r)
    }),
    $.ajax(…).done(function(r) {
        console.log("ajax 2 resolved with", r)
    })
).done(function(r1s, r2s) {
    console.log("both ajax requests done");
});

다른 팁

You'd have to set each ajax call as a deferred object and then set the deferred objects to resolved in the .then() method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top