jQuery ajax problems in IE8

As usual, everything works except IE8. Horrible crapware.. *sigh*

My jQuery Ajax request kept on returning the same result in IE8 even though everything worked perfectly fine in the other browsers.. Turns out IE caches the result and only performs an ajax request if the page has expired, or if it has not been previously cached. Supposing the same URL will Always result in the same data (Very 90s way of thinking considering most pages these days, being generated on the go, wont yield the same exact page twice..)

As such, getting the page to load decently requires you to put in some extra code. Not that much trouble, but utterly annoying to look for when debugging the code when it doesnt work in IE as usual.

The possible solutions?

  • Set “$.ajaxSetup ({ cache: false });” in jQuery – didnt work for me
  • Add a random string to the end of the url – Talk about a dirty fix, but it does work
  • Set the page expiration date accordingly (For the page answering the ajax request), in cgi for my case: print header( -expires=>’+1s’ , );

One of those ll do it. I obviously implemented the last one, the rest being rather dirty in my eyes..

Check http://stackoverflow.com/questions/168963/stop-jquery-load-response-from-being-cached for more on this

Thank you, IE, for wasting my time. It should be taken out back and shot.

Published by Gert


One thought on “jQuery ajax problems in IE8

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: