JSON breaking back button in Chrome, Reload Button in IE (Showing as naked data) JSON breaking back button in Chrome, Reload Button in IE (Showing as naked data) google-chrome google-chrome

JSON breaking back button in Chrome, Reload Button in IE (Showing as naked data)


The problem was actually Rails: Both Chrome and IE request the last response with no specific format, so Rails just takes the first response block, which happened to be json in my case. Putting the html block in front of the json block solved the issue.

respond_to do |format|  format.html { ... } //important because the request comes with no specific format  format.json { ... }end


I had the same problem with Chrome. My controller's method does have the format.html

respond_to do |format|  format.html  format.jsend

It seems that Chrome caches results, so I was able to fix this by adding a data entry to my ajax request, like so:

$.ajax({   url: '/restful/path',   data: { format: 'js' }, // This line here   dataType: 'json'});

or you can pass the format by attaching it to the end of the request, just make sure you have the (.:format) option in your route

$.ajax({   url: '/restful/path.js',   dataType: 'json'});

Hope this helps someone