JQuery get ajax call not working in IE
Posted in JQuery on May 5th, 2010 by taswar
So for some reason IE just loves to cache things for you when you call an ajax method.
Something like
1 2 3 4 5 | $('#mybutton').live('click', function() { $.post('SaveLanguage', { lang : $(this).val(), null, null); $.get('GetLanguage', null, function(html) { $('#myDiv').replaceWith(html); }); }); |
This will work every time in firefox but IE will just call the cache version, thus whatever you have changed in the post version would not matter.
To fix this one can use datetime to append to the query string in each call or just use jquery ajaxSetup like
1 2 3 4 5 6 7 | $.ajaxSetup({ cache: false}); $('#mybutton').live('click', function() { $.post('SaveLanguage', { lang : $(this).val(), null, null); $.get('GetLanguage', null, function(html) { $('#myDiv').replaceWith(html); }); }); |
or use the $.ajax call and pass in cache: false.
2 Responses
Leave a Comment

August 3rd, 2010 at 2:10 pm
great! I just changed get to post and now it’s working everytime in IE
December 7th, 2010 at 1:07 am
Wonderful ! I was having the same problem . It helped me a lot to fix .Many thanks .