I have a form which submit a form via AJAX with :remote => true. Looking at the server log and FireBug, I get the response 200 OK and it returns JSON in the form of:
(On Rails 5.2 and jQuery 2) I spent an hour comparing two bits of UJS code side-by-side to no avail: both return a similar format Javascript function call (to update the front-end), and a status of 200 but one triggers ajax:error
and the other doesn't. I was able to eliminate the problem by switching from jquery_ujs to rails-ujs in the application.js manifest:
//= require jquery2
// require jquery_ujs # Removed this by taking away '='
//= require rails-ujs
Note the hyphen vs the underline!
Now both calls behave the same (correct) way. I hope this helps someone else.