I was experiencing a bug in IE7 where my Rails app would return js when I was asking for html and vice-versa.  It worked fine in other browsers but just not IE.  It seems a few other people were having this issue long ago but I could not find any recent info or a complete solution.  I quickly figured out that the order of my format statements in my respond_to block affected the result that I got from my reqeust.  So I could rearrange those and get the result I wanted.  But the problem was that I needed both at different times in my app.  That’s why you have them right?  Anyway, after reading over  a related post at info.michael-simons.eu I discovered that IE was sending the wrong accept-headers.  So I checked out the Prototype API and learned that I could set my accept-header for my ajax requests.  So I added  accept:'text/javascript' to my ajax options and it worked.  This was a real stickler for me so I wanted to document it here for others that were stuck on it.

Here is what my ajax request looked like:

new Ajax.Request(url, {
method: 'get',
parameters: params,
onCreate: function() {

Update: Looks like Paul Stadig might have a cleaner option. I haven’t tried it, but it looks like it might be the better way to go.

Average Rating: 4.6 out of 5 based on 182 user reviews.