I have added success and failure handlers to a :remote => true link generated by rails:

HAML:

link_to 'Cancel', cancel_path(block), :method => :delete, :remote => true, :id => "cancel-button"

JS:

 $('#cancel-button').live('ajax:failure', function(){console.log('failure');});
 $('#cancel-button').live('ajax:success', function(){console.log('success');});

When the response from the server is 200 the console output works - success.

When the response from the server is 404, neither of these handlers fire. No output.

The same is true when the server returns a 500 status - no output.

Any ideas why rails.js might not be catching this?

Thank you!

link|flag

1 Answer

Whoops. Contrary to the blog post I was reading the name of the event is actually ajax:error rather than ajax:failure...

link|flag

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.