Internet Explorer Issue with javascript

Discussion in 'JavaScript' started by 3.5supersonic, Jun 24, 2010.

  1. #1
    Hi

    I have below JavaScript on a php file and it works great on firefox but not in IE8

    i found the problem and it was due to caching. at first time page load IE cache php file and showing cached php file on intervals

    <?php
    print <<<HERE
    <script type="text/javascript">
    $(document).ready(function() {
    $("#loader").load("content.php?uname=$uname");
    var refreshId = setInterval(function() {
    $("#loader").load("content.php?uname=$uname");
    }, 5000);
    });
    </script>
    HERE;
    ?>
    <div id="loader"></div>
    Code (markup):
    is there way to prevent cache with the page or JavaScript? or a better JavaScript to do the same thing which compatible with IE

    Any help would be great and sorry for language errors

    Thanks
     
    3.5supersonic, Jun 24, 2010 IP
  2. wgcom

    wgcom Peon

    Messages:
    157
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    make sure you sending right http headers to prevent client caching ...
    or (quick and dirty) add random param value to the URL.
     
    wgcom, Jul 4, 2010 IP
  3. Sabbir

    Sabbir Banned

    Messages:
    210
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #3
    You can try Adding this line to Html file
    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

    I think it needs to be added twice, before <body>and after</body>
    Both time inside head tag.
     
    Sabbir, Jul 4, 2010 IP