I'm using Rails 3 and JQuery 1.4.2 and am trying to bind to the ajax:failure callback on a given remote form submission. The callback works fine, however, the xhr variable that's passed back seems to lose the responseText attribute somehow.
Here's what my code looks like:
_form.html.haml
= form_for(object, :remote => true) do |f|
= form fields and such...
Javascript somewhere...
$('form').livequery('ajax:loading', function() {
// what to do on ajax loading
}).livequery('ajax:success', function(data, status, xhr) {
}).livequery('ajax:failure', function(xhr, status, error) {
alert(xhr.responseText);
});
I'm basically rendering the object's error messages from the controller so that I can display error notifications on this callback. The weird thing is I go into rails.js, lines 49-51
error: function (xhr, status, error) {
el.trigger('ajax:failure', [xhr, status, error]);
}
and manually write to the console responseText, it works the way I would expect.
Am I doing something wrong? How would the xhr object change from the rails.js to my bind?