你真正需要的ID發送到服務器端控制器處理Ajax請求。 可用性的一個好方法,在你的心中,你可以在任何情況下使用兩個位。 首先位置將具有所述請求和所述第二數據例如JSON數據或任何其他的ID。 當服務器端完成其工作,它在一個陣列也是同樣的模式,ID,數據和你做響應發送回頁面。您可以在頁面中發送異步,而不用擔心混淆請求。
function request1(){
data=getdata;
arrData={1,data};
ajaxsent(controler,data,onresponse1);
}
function request2(){
data=getdata
arrData={2,data};
ajaxsent(controler,data,onresponse2);
}
function request3(){
data=getdata;
arrData={3,data};
ajaxsent(controler,data,onresponse3);
}
function request4(){
data=getdata;
arrData={4,data};
ajaxsent(controler,data,onresponse4);
}
function onresponse1(xml){
synchronizer(xml);
}
function onresponse2(xml){
synchronizer(xml);
}
function onresponse3(xml){
synchronizer(xml);
}
function onresponse4(xml){
synchronizer(xml);
}
function synchronizer(xml){
switch(xml.id)
case 1: dostuff;
case 2: dostuff;
case 3: dostuff;
case 4: dostuff;
}
見梅德的答案;我假設是因爲'FunctionWhichDoesMoreAjax()'之前的'return',你最終試圖從其成功回調中返回一個值。對困惑感到抱歉。 –