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