(Multiple jsonp requests at the same time will report an error)
a();
b();
For example, it is judged that a has been executed before executing b;
code show as below:
function Page() {
this.init();
}
Page.prototype = {
init: function () {
this.a();
this.b();
},
ajaxDataCrossDomain: function (config) {
var _this = this;
var result;
$.ajax({
type: "GET",
cache: false,
async: false,
url: "",
data: data,
dataType: "jsonp",
jsonp: 'callbackparam',
success: function (data) {
// 在这里的返回值也无法指定给 result
}
})
},
a: function () {
var _this = this;
var result;
_this.ajaxDataCrossDomain({
"url": "a.php",
"mydata": {
},
"mysuccess": function (data) {
},
})
},
b: function () {
var _this = this;
var result;
_this.ajaxDataCrossDomain({
"url": "b.php",
"mydata": {
},
"mysuccess": function (data) {
},
})
},
}
我想大声告诉你2017-06-30 10:00:11
promise
$.ajax(...)
.then(res => {
...
return $.ajax()
})
.then(....)