views:

634

answers:

2

Hi,

I have the following jquery code:


function update(){
    $.get("getlatest.php", {
        id: $.cookie('last_post_id')
    }, function(response){


        $('#board_posts').prepend(response);
        $('.incoming_post').slideDown("slow").effect("highlight", {}, 3000);
        $('.incoming_post').toggleClass("incoming_post").addClass("old_post");



    }, "html");
}

The function will check if there are any new posts to the message board, and if so, will load them. For some reason, new data never loads in IE 7, but loads fine in FF and Chrome. Moreover, when I refresh the page, the data doesn't come in either - only when the cache is cleared.

Any help on this issue?

+2  A: 

Use the jQuery.ajaxSetup method to set the cache option to false. Alternatively use the $.ajax method to do the same thing.

kgiannakakis
+5  A: 

Internet Explorer caches requests. See the cache flag for jQuery Ajax requests. It will add a random query string parameter to the URL (based on the current time) to make it unique and uncacheable. You can do this yourself as well if you like: 'request.php?_=' + (+new Date())

Blixt
+1. Not everyone really realizes about this strange behavior of IE and end up blaming their own codebase. But firefox works as expected. Good thing is, always send a random parameter while using Ajax. Intentional caching is exception.
simplyharsh