【发布时间】:2019-09-12 08:44:40
【问题描述】:
我已经使用 JQuery 很长时间了,我对其中的 AJAX-Calls 很熟悉。我经常遇到这样的情况,我必须等到多个请求完成后再继续处理结果。
JQuery 语法如下:
$.when(
$.ajax({
type: "POST",
url: '/Services/Service.asmx/GetResults1',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
...
},
error: function (e) {
console.log('ERROR! ' + e.responseText);
}
}),
$.ajax({
type: "POST",
url: '/Services/Service.asmx/GetResults2',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
...
});
},
error: function (e) {
console.log('ERROR! ' + e.responseText);
}
})
).done(function (result1, result2) {
// Do s.th. with result1 and result2 what is already
// available here
updateUI();
...
});
你如何在 VanillaJS 中做到这一点?
【问题讨论】:
标签: javascript ajax asp.net-ajax