Blog

Some of my recent posts and ramblings.

IE caching ajax responses

Another one from IE. It never runs out of new ways to screw our lives. On one of our sites, the client kept coming back saying the person they just entered doesn’t show up in a dropdown list which was being populated by ajax based on a type selection. We used to test it on Firefox and Chrome and never bothered to check it in IE since it was not a CSS issue. Until finally one of our testers detected it, it was only in IE. Searching for it led me to this article on Ajaxian. Apparently IE, the super intelligent browser that it is, decided to cache ajax responses which none of the other browsers do.

To resolve this, either use a POST or if you have to use GET or want to fix it with minimal code change, add a variable with a unique or random number value for each request. So my request changed from

    $.getJSON("/getPersonList/",{type: $("#type").val()}, function(j){ });

to

    $.getJSON("/getPersonList/",{type: $("#type").val(), rand:Math.floor(Math.random()*100001)}, function(j){ });


One comment.

  1. Romby

    Awesome you should think of somhneitg like that


Leave a Reply

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>