Javascript ionic 3中的递归jquery ajax请求
这段代码摘自一个ionic框架项目。如果第一个(初始)请求返回某个(例如418)http状态代码,我想在ajax请求中发出另一个请求。当我调用“makeRequest()”时,它返回418状态代码,这是正常的,然后当我使用获得的不同数据发出第二个请求时:Javascript ionic 3中的递归jquery ajax请求,javascript,jquery,ajax,angular,ionic-framework,Javascript,Jquery,Ajax,Angular,Ionic Framework,这段代码摘自一个ionic框架项目。如果第一个(初始)请求返回某个(例如418)http状态代码,我想在ajax请求中发出另一个请求。当我调用“makeRequest()”时,它返回418状态代码,这是正常的,然后当我使用获得的不同数据发出第二个请求时: makeRequest(where, data, type?) { if (!type) { type = 'GET'; } $.ajax({ method: type,
makeRequest(where, data, type?) {
if (!type) {
type = 'GET';
}
$.ajax({
method: type,
url: baseaseUrl+where,
data: data,
success: function (msg) {
console.log('ajax: ', msg);
return msg;
},
error: function (a, b, data) {
console.log(b + ' ' + data);
},
statusCode: {
418: function(status) {
console.log('418: ', status.status);
return makeRequest(where, different_data);
}
}
});
}
ERROR RangeError: Maximum call stack size exceeded
at Function.jQuery.extend.jQuery.fn.extend (vendor.js:1)
at Function.jQuery.extend.jQuery.fn.extend (jquery.js:250)
at Function.jQuery.extend.jQuery.fn.extend (jquery.js:250)
at Function.jQuery.extend.jQuery.fn.extend (jquery.js:250)
at Function.jQuery.extend.jQuery.fn.extend (jquery.js:250)
at Function.jQuery.extend.jQuery.fn.extend (jquery.js:250)
at Function.jQuery.extend.jQuery.fn.extend (jquery.js:250)
at Function.jQuery.extend.jQuery.fn.extend (jquery.js:250)
at Function.jQuery.extend.jQuery.fn.extend (jquery.js:250)
at Function.jQuery.extend.jQuery.fn.extend (jquery.js:250)