jQuery Ajax call in IE

Compatibility issues are a huge problem for software developers. We are constantly checking and rechecking work to make sure that everything goes right and nothing hurts us down to our core more than when our customers want something that will run as smoothly on IE 7 as it does on today’s browsers.

Making the jQuery request work in IE (Internet Explorer)

Most clients don’t understand the difference or refuse to upgrade or can’t upgrade… and that’s where the problems always start. Most developers I have met have a common distaste for Internet Explorer. When browsers like Chrome, Safari and Firefox came out we all found out just how much compatibility issues would plague us for years to come.

Now, things have SLOWLY improved, especially with the current run of browsers including IE 10 (which is only available for users who have Windows 8). But these issues still arise more often than we’d like.

I have come across one particular issue a lot, and I always seem to forget about it when I start building a new project.

Internet Explorer has a cache issue when it comes to jQuery Ajax calls. What this means is that when an jQuery Ajax call is made in Internet Explorer it has to be unique or the browser won’t allow the Ajax request. None of the other major browsers have this issue. Usually the problem starts with the phrase: “Hey I found this weird thing in IE”. I start my usual debugging techniques of going through and figuring out when and where the code is breaking, I scratch my head, drink some coffee, stare confusedly at my screen before eventually planning to go play in the middle of a busy intersection… at night… wearing black… Then I remember the caching issue… and it’s simple fix.

I generally add this as high as level as possible (something that is going to be on every page, like a global JavaScript file): $.ajaxSetup({ cache: false });

There it is, problem solved. What this line does is add an arbitrary time-stamp to every Ajax request making it (in IE’s programming) a different, unique request.