Rails unobtrusive ajax:failure event not firing
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!
Whoops. Contrary to the blog post I was reading the name of the event is actually ajax:error
rather than ajax:failure
...
精彩评论