$.when(postrequest1, postrequest2).then(function (data1,data2) {
// data1, data2 are arrays of the form [ "success", statusText, jqXHR ]
});
Simply give data arguments to the anonymous callback function. See $.when() for more details.
Question
This is the basic framework of my page:
$.when(postrequest1, postrequest2).then(function () {
// how do I access the results of postrequest1 and postrequest 2 here?
});
Solution
$.when(postrequest1, postrequest2).then(function (data1,data2) {
// data1, data2 are arrays of the form [ "success", statusText, jqXHR ]
});
Simply give data arguments to the anonymous callback function. See $.when() for more details.
OTHER TIPS
Have you tried this?
$.when(postrequest1, postrequest2).then(function (postData1, postData2) {
});
(As long as the post requests are single requests, otherwise the then
params can be arrays)
try this
$.when(postrequest1, postrequest2).then(function (a1,a2) {
var jqXHR1 = a1[2]; /* arguments are [ "success", statusText, jqXHR ] */
alert(jqXHR1.responseText);
var jqXHR2 = a2[2];
alert(jqXHR2.responseText);
});
a1 and a1 are arguments for 1st and 2nd ajax request respectively...
a1 and a2 are array each having keys as (success,statusText,jqXHR)
you can then handle them individually.
Documentation :http://api.jquery.com/jQuery.when/