When trying to make a jQuery ajax request, don’t get JSON happy and set everything to JSON. Read the documentation instead.
contentType - When sending data to the server, use this content-type.
dataType - The type of data that you’re expecting back from the server.
If you set contentType to application/json and try to make ajax POST requests with a serialized form, crazy stuff happens. If you don’t set a dataType and try to hit a controller that responds to both html and js, you’ll get the html.
respond_to do |format|
format.html
format.js { render :json => @health_reform.to_json }
end
If you have a link that you’ve unobtrusively turn into an ajax request on click and your browser is downloading a crazy text file when you click the link, you forgot the “return false” at the end if your click event.
map.connect ‘justin_bieber/:age’, :controller => ‘justin_bieber’, :action => ‘show’ will catch ‘http://localhost:3000/justin_biebers’ and throw you an age not found error. Be sure to put whatever route handles the index action above the show action if you aren’t using resources.