gor*_*mit 2 asp.net ajax jquery
如何从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
}
});
Run Code Online (Sandbox Code Playgroud)
你可以试试这个:
error: function(msg, status) {
if (status === "error") {
var errorMessage = $.parseJSON(msg.responseText);
alert(errorMessage.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1695 次 |
| 最近记录: |