Quick Fix: 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 🙂
Comments have been disabled.