If I use jQuery ajax with an error handler and the ASP.NET MVC action that I'm invoking throws an exception, I'd like to be able to display the message in the exception to the user. Right now I'm using:
$.ajax( {
...
error: function(request,status,error) {
var exp = new RegExp('<title>(.*)<\/title>','i');
if (exp.exec(request.responseText)) {
alert( RegExp.lastParen );
}
else {
alert( status );
}
}
});
I'm hoping for a canonical jQuery implementation, rather than rolling my own.