...

View Full Version : Resolved Content not updating in IE



[vengeance]
12-04-2009, 01:52 PM
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:


<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:


<div id="count"></div>


Can anyone see what my problem is? And any workarounds for this?

mattyod
12-04-2009, 04:05 PM
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.

[vengeance]
12-04-2009, 04:14 PM
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. :confused:


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. :confused:

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



$.ajaxSetup ({
cache: false
});



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum