Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts

    Content not updating in IE

    Hello.

    I'm creating a simple auto updating script based on PHP and using jQuery to set the interval to 1000 miliseconds. It works in FireFox, as the only one I've tested so far, but in Internet Explorer (Version 7 right now, didn't test others) it just freezes and doesn't auto update. Doesn't auto update either if I refresh the page, so something's messed up here.

    I'm using the same way of auto updating on other things, such as a chat-page - works on those in all browsers, so I'm kinda on a lost track here.

    Here's the JavaScript/jQuery:
    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript">
    function loadContent() {
    	$('#count').load('counter.php', function() {
            setTimeout("loadContent()", 1000);
        });
        return false;
    }
    $(loadContent);
    And this is what I put on the body of the page:
    Code:
    <div id="count"></div>
    Can anyone see what my problem is? And any workarounds for this?
    Last edited by [vengeance]; 12-04-2009 at 09:51 PM.

  • #2
    New Coder
    Join Date
    Feb 2005
    Posts
    97
    Thanks
    7
    Thanked 7 Times in 7 Posts
    I'm surprised it works in any browser.

    Your jQuery references the id "#count" but your html has a div with the id "countopening".

    Once you correct the id you'll probably find that IE only loads that once though. Tends to cache ajax requests rather stupidly, so often a work around is to add a random number or new date as a query string to the url request.

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by mattyod View Post
    I'm surprised it works in any browser.

    Your jQuery references the id "#count" but your html has a div with the id "countopening".

    Once you correct the id you'll probably find that IE only loads that once though. Tends to cache ajax requests rather stupidly
    Sorry about that, edited it in the script, forgot to do that here.
    And yes, IE only loads it once.

    so often a work around is to add a random number or new date as a query string to the url request
    Can you give me an example of this?


    Edit: I just tried appending a Math.random() value upon every single load - the random number changes in all browsers. But the load itself freezes in IE. It only loads the counter.php once, even though I set an interval to it... I tried different things but seems like it's frozen after the first load.

    Edit 2: Nevermind, supposedly it worked after I added this:

    Code:
    $.ajaxSetup ({  
    	cache: false
    });
    Last edited by [vengeance]; 12-04-2009 at 09:51 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •