我需要調用從阿賈克斯成功方法onSuccessLogin方法,或將響應作爲參數爲onSuccessLogin。 謝謝你的答案。如何從嵌套ajax(成功)方法調用外部方法?
submit: function (form) {
$.ajax({
type: "post",
url: "/login",
data: {
login: $(form).find('#login').val(),
password: $(form).find('#password').val(),
deviceType: environmentInfo.browser,
sdkVersion: environmentInfo.browserVersion,
osVersion: environmentInfo.OS
},
success: function(res) {
localStorage.setItem("languagesList", res);
//how to call onSuccessLogin method from here?
},
\t //Another implementation
// success: this.onSuccessLogin(res), - dosen't work, if I want put response from ajax into this method call
error: this.onErrorLogin
});
},
onSuccessLogin: function() {
//localStorage.setItem("languagesList", res); get response from second implementation
window.location = "/";
}
謝謝你,這對我有用。 – Arsenowitch