Check the request returned status to determine if there is an error or just do it like
if(jqXHR === 0 ){
//do something with error
} else {
//success
}
Edit:
Try this
"A block of code to run if an error occurs"
$.ajaxSetup({
error: function(res){
$('body').prepend(res.responseText)
}
});
For one method
def new
@item = Item.new
rescue
render 'shared/exception', :layout => 'overlay'
end
For the whole app
class ApplicationController
around_filter :xhr_exceptions
# ...
private
def xhr_exceptions
yield
rescue
render('shared/exception', :layout => 'overlay', :status => 500) if request.xhr?
end
end
http://codequietly.com/blog/2010/08/rails-ajax-and-exceptions-bring-it-on if its dead try cached