QuickFix: jQuery $.getJSON() fails in IE6 & IE7
Had a nasty issue with jQuery + jSON + IEx just now – still at work because of it!
This bit of code works perfectly fine on Firefox and Chrome:
function onUnitsModified() {
$.getJSON("<%=Url.Action("GetTotalUnitCount", "ProjectReaper")%>", null, function(result) {
if(result > 0)
// Do stuffs here
}
});
return true;
}
But in IE we’ve come to realise that the first hit is successful, future json requests ones are not hitting the ASP.NET MVC actions (I put a breakpoint). You could append a time stamp to get rid of this annoying caching bug, but alternatively you can use the ajaxSetup options to disable caching.
function onUnitsModified() {
$.ajaxSetup ({ cache: false});
$.getJSON("<%=Url.Action("GetTotalUnitCount", "ProjectReaper")%>", null, function(result) {
if(result > 0)
// Do stuffs here
}
});
return true;
}
Darnit! Hope someone else doesn’t waste their time trying to fix this now
Related posts:

Thanks, this has been driving me nuts all week! You saved me a few more days of head scratching
Thanks a lot. This is the quickest fix ever.
Thanks a lot,!
Grrrrr… just spent two hours on this! Thanks!!!
One of the gr8 and fastest fix ever………thanks!!!!!!!!!
Thank you for saving time…
Awesome……. I’ve been trying ot fix this issue for the last 2 days now….
Thanks soo much…
Thank you !!!!!
Thank you very much. I tried several ways but din’t work. Thanks for the post.
Thnx help alot , clearing cache from server side didnot solve the problem , but $.ajax done the game . cheers Thanx alot for posting this
Hi,
Thanks a lot….
Hi..
I used this line in my javascript function
$.ajaxSettings.cache=false;
in place of
$.ajaxSetup ({ cache: false});.
So i want to know, which one is best to sort out this problem.
Please reply…
I love you for this!!!
$.ajaxSetup({ cache: false }); is the way. You saved me days.