I have a rails 3 remote form tag that I am trying to submit via ajax, from what I can see things seem to be working alright but for some reason the ajax:success event is never fired but the ajax:error always is. When I open Firebug I can see the request is returning with a 200 status… I thought a 200 status would trigger the ajax:success am I missing something? Here is my javascript:
$('#institution-select-form')
.bind("ajax:complete", function() {
alert('complete!');
})
.bind("ajax:beforeSend", function () {
alert('loading!');
})
.bind("ajax:error", function (xhr, status, error) {
alert('failure!');
})
.bind('ajax:success', function(event, data, status, xhr) {
alert('success!');
});
The error event can be triggered by other issues, not just a non-200 status. For example, if you’re returning JSON or XML and the data being returned is invalid and can’t be parsed, that will result in an error event.
To diagnose it, add to your ajax:error function: