这是我的页面的基本框架:如何返回.post加载的页面的内容,封装在.when中时?
$.when(postrequest1, postrequest2).then(function() {
// how do I access the results of postrequest1 and postrequest 2 here?
});
这是我的页面的基本框架:如何返回.post加载的页面的内容,封装在.when中时?
$.when(postrequest1, postrequest2).then(function() {
// how do I access the results of postrequest1 and postrequest 2 here?
});
$.when(postrequest1, postrequest2).then(function (data1,data2) {
// data1, data2 are arrays of the form [ "success", statusText, jqXHR ]
});
,只需提供数据参数的匿名回调函数。有关更多详细信息,请参阅$.when()。
肯定的,但将所述'数据变量包含来自postrequest1或postrequest2的内容? – think123 2013-04-09 10:01:29
@ think123:见编辑。 – Manishearth 2013-04-09 10:08:55
试试这个
$.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和A1对于第一次和第二次分别Ajax请求的参数......
A1和A2阵列每个都具有键作为(success,statusText,jqXHR)
可以再处理他们单独。
请参阅http://api.jquery.com/jQuery.when/ – alwaysLearn 2013-04-09 10:14:02
你试过吗?
$.when(postrequest1, postrequest2).then(function (postData1, postData2) {
});
(只要交请求是单个的请求,否则then
PARAMS可以是阵列)
http://api.jquery.com/jQuery.when/ – undefined 2013-04-09 10:07:22