如何在发送前调用仅成功?现在,当错误进入ajax调用时,我的按钮也将文本更改为“正在工作”。
success: function(data) {
alert("operation successful");
},
beforeSend: function() {
btnSubmit.val("Working...");
},
error: function(response) {
alert("something went wrong");
}
答案 0 :(得分:1)
使用"完成"改变按钮文字
完成:请求完成时要调用的函数(执行成功和错误回调后)
success: function(data) {
alert("operation successful");
},
beforeSend: function() {
btnSubmit.val("Working...");
},
error: function(response) {
alert("something went wrong");
},
complete:function() {
btnSubmit.val("Done");
}
}