I have some ajax code on the client side like this:
$.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
and on the server side:
<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
The failure message is not called. Why is this?