I have a page that saves data using jQuery AJAX. On the server side, if the saving process fails, I want to set the StatusDescription of the Response object to "Hey this is Patrick!". The problem is, I can't display the StatusDescription on the client side! It always give me "Internal Server Error". How can I display my custom error message?
Save.ashx
Catch ex As Exception
Transaction.Rollback()
context.Response.StatusCode = 500
context.Response.StatusDescription = "Hey this is Patrick!"
End Try
AJAX
$.ajax
({
type: 'POST',
url: 'Save.ashx',
data: data,
async: false,
success: function(Data, TextStatus, XHR) {
alert(Data);
},
error: function(XHR, TextStatus, ErrorThrown) {
alert(ErrorThrown);
}
});