How to process msg returned from jquery.ajax()
开发者_StackOverflow中文版I would like to know what are the properties of msg object from jquery.ajax(). I am throwing an exception inside asp.net static function, but I am unable to cast it in javascript.
Thanks for help
You can read the response from your .Net page e.g.
$(function(){
$.ajax({
type: 'POST',
url: "test.aspx",
data: "ref=test",
success: function(r) { },
error: function(r) { alert(r.toString()); }
});
});
You can then read the error message and do the necessary steps..
If you have exception in the Server-Side, then JavaScript couldn't catch the Exception cause JavaScript is in the Client-Side.
You can catch the exception by yourself in Server-Side and send a custom error message to Ajax "success function" to handle the error(Exception) you thrown
精彩评论