我在客户端有一些ajax代码,如下所示:
$.ajax({
type: "POST",
url: "frmPNList.aspx/ChangeGroupOfUSNs",
async: false,
contentType: "application/json; charset=utf-8",
//data: '{strNewUSN: "' + usn.value + '", strURNs: "' + id[1] + '", strDatasetName: "' + id[2] + '", strCon: "' + $("#<%=fieldGenieConnectionString.ClientID%>")[0].value + '"}',
data: '{strNewUSN: "' + usn.value + '", arrayURNDataset: ' + JSON.stringify(strURNDataset) + ', strCon: "' + connectionstring.value + '", strUserNameLocal: "' + username.value + '"}',
//data: '{strNewUSN: 9, strURNs: 1, strDatasetName: 2}',
dataType: "json",
success: OnSuccess(),
error: function (xhr, errorType, exception) {
var errorMessage = exception || xhr.statusText; //If exception null, then default to xhr.statusText
alert("there was an error changing the USN of the group: " + errorMessage);
},
failure: function () {
alert('there was an error changing the USN of the group.')
}
});
function OnSuccess() {
return function () {
}
}
//end of AJAX call在服务器端:
<System.Web.Services.WebMethod()> _
Public Shared Sub ChangeGroupOfUSNs(ByVal strNewUSN As String, ByVal arrayURNDataset As String, ByVal strCon As String, ByVal strUserNameLocal As String)
Try
Throw New Exception
Catch ex As Exception
End Try
End Sub不调用失败消息。为什么会这样呢?
发布于 2016-02-17 23:04:22
只有当请求本身出现问题(错误404、错误500等)时,才会触发失败。它不会返回PHP/ASP错误。
如果你想检查PHP/ASP错误,你必须自己做(在done函数中,你可以创建一些If语句)。
https://stackoverflow.com/questions/35460226
复制相似问题