Rails Remote => True Confusion (no Format.js?)
Solution 1:
I found the answer i was looking for on IRC. The answer is from https://www.alfajango.com/blog/rails-3-remote-links-and-forms-data-type-with-jquery/:
Newer versions of the UJS driver simply leave jQuery's default dataType of '/'. This tells the server, "Give me whatever you've got." However, this would make the controller respond with the first format that happens to be listed in the Responder (see next section). So if format.html is listed before format.js, the app will respond with the HTML response (which means it will try redirecting for POST or DELETE method AJAX requests). This isn't ideal either.
So in the newest versions, we figured out how to set the default, such that it tells the server, "I'd prefer JS, but I'll take whatever you've got." Now, if format.js is defined at all in the available Responder formats, JS will be returned. If not, the controller will then respond with the first format listed. (See the discussion thread here.)
discussion thread: https://github.com/rails/jquery-ujs/issues/74
Post a Comment for "Rails Remote => True Confusion (no Format.js?)"