我正在尝试将函数 ajaxFailureHandler
附加到 ajax
请求中:
$.ajax({
url: GlobalVariables.baseUrl + '/dashboard_api/ajax_save_user',
dataType: 'text',
cache: false,
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function (response) {
alert(true);
}.bind(this),
error: function (response) {
alert(false);
}
}.bind(this), 'json').fail(GeneralFunctions.ajaxFailureHandler);
但我实际上得到了这个错误:
Uncaught TypeError: {(intermediate value)(intermediate value)(intermediate value)(intermediate value)(intermediate value)(intermediate value)(intermediate value)(intermediate value)(intermediate value)}.bind is not a function
我可以做什么来解决这个问题?
最佳答案
您已将要传递的设置对象绑定(bind)到 $.ajax()。我想你可能想像这样绑定(bind)错误函数:
$.ajax({
url: GlobalVariables.baseUrl + '/dashboard_api/ajax_save_user',
dataType: 'text',
cache: false,
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function (response) {
alert(true);
}.bind(this),
error: function (response) {
alert(false);
}.bind(this)
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
关于javascript - 无法将函数绑定(bind)到 ajax 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53870222/