这是两个电话——
var url = '/Home/ListData?ipaddress=' + ipaddress;
processAjaxRequest(url , 'Post', 'fetchDataComplete', DataModel);
processAjaxRequest('/Home/ListException', 'Post', 'fetchExceptionComplete',DataModel);
function processAjaxRequest(urlToProcess, httpMethod, successCallback, postData) {
$.ajax({
url: urlToProcess,
type: httpMethod,
data: dataToPost,
success: function (data, status) {
var fn = window[successCallback];
fn(data);
},
error: function (xhr, desc, err) {
processAjaxError(xhr, desc, err);
},
});
}
function fetchDataComplete(data) {
//some stuff
}
function fetchExceptionComplete(data) {
//some stuff
}
如果我更改 ajax 调用的顺序,它将继续执行最后一个函数的回调方法。我希望两者都被执行。