如何从 webmethod 获取错误消息,我想启动错误。另外,我希望在不同的场合有不同的错误消息。
$.ajax({
type: "POST",
url: "betting.aspx/submitFunction",
data: JSON.stringify({ results: jsonObj, edit: $("#ctl00_ContentPlaceHolder1_CreateOrEdit").val() }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(arg) { //call successfull
window.location = "bHistory.aspx";
},
error: function(xhr) {
alert("Error! You need to login, and try again");
window.location = "login.aspx";
//error occurred
}
});
你可以试试这个:
error: function(msg, status) {
if (status === "error") {
var errorMessage = $.parseJSON(msg.responseText);
alert(errorMessage.Message);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)