Ajax.PeriodicalUpdater not working with IE

57 views
Skip to first unread message

Gerrit

unread,
Jun 12, 2007, 7:56:54 AM6/12/07
to Ruby on Rails: Spinoffs
Hi!
I spent 2 days now, getting Ajax.PeriodicalUpdater working with IE,
but I had no success. There is no problem with Firefox or Konqueror
and it works as aspected.
In IE the content (output from a php script) is downloaded once, but
never gets updated after that. Interestingly enough the content gets
updated when I open the php script in another browser window and
update it. There seems to be a problem with caching!?
At first I thougt this is a general problem with IE, but using
equivalent code with mootools, the content gets updated periodically!

Is this a bug or am I just terribly stupid? ;-)
You can find my test code below
----------------------------
<html>
<head>
<title>test</title>
<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1980 1:00:00 GMT">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<script type="text/javascript" src="prototype.js"></script>
</head>

<body>
<div id="time"></div>
<script type="text/javascript">
Event.observe(window, 'load', doUpdate(), false);
function doUpdate() {
new Ajax.PeriodicalUpdater('time', 'time.php',
{
method: 'get',
frequency: 1
});
}
</script>
</body>
</html>
----------------------------
time.php just contains <?php echo date("H:i:s"); ?>

Adam McCrea

unread,
Jun 15, 2007, 10:43:41 AM6/15/07
to Ruby on Rails: Spinoffs
Couple things...

First, in your Event.observe call, remove the parenthesis from
doUpdate() so you pass the function itself rather than calling it.

Second, you don't actually need to use the load event since your JS
follows the "time" div. The div has been loaded into the DOM, so you
can go ahead and reference it. If you put your script in the header
(which I would), then you need the load event.

All that said, your code should still create the PeriodicalUpdater.
Make sure you're not getting a security warning in IE, and also try
retrieving a static text file.

Gerrit

unread,
Jun 16, 2007, 7:41:56 AM6/16/07
to Ruby on Rails: Spinoffs
Thanks for your message!
I have changed the html file to your suggestions, but the container
still doesn't get updated in IE.
I have also tried a static text file and changed it while IE was
running but it still showed the old value.
But I have found something else interesting, if you clear IE's cache,
the value gets updated once.
It would be very nice if anybody else could try this and say if it
works or not. I have no further ideas...

Just to make sure I got you right Adam, this is the changed html file:
----------------------------
<html>

<head>

<title>test</title>

<META HTTP-EQUIV="Expires" CONTENT="Tue, 01 Jan 1980 1:00:00 GMT">

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<script type="text/javascript" src="prototype.js"></script>

<script type="text/javascript">
Event.observe(window, 'load', doUpdate, false);
function doUpdate() {
new Ajax.PeriodicalUpdater('time', 'test.txt',

/*new Ajax.PeriodicalUpdater('time', 'time.php',*/

{

method: 'get',

frequency: 1

});
}

</script>
</head>

<body>


<div id="time"></div>

</body>

</html>
----------------------------

tobie

unread,
Jun 18, 2007, 4:07:33 PM6/18/07
to Ruby on Rails: Spinoffs
Sound like you're not setting up correct headers on your server.

Have a look at this: http://en.wikipedia.org/wiki/XMLHTTP#Microsoft_Internet_Explorer_cache_issues

Please close the trac ticket you reopened if that solves your issue.

Thank you.

Gerrit

unread,
Jun 18, 2007, 5:00:01 PM6/18/07
to Ruby on Rails: Spinoffs
Yes, it works now! :) Thank you very much Tobie, this problem has
driven me insane...
I think this should be mentioned in the API Docs or sowewhere else!
If you are not familiar with that, you will probably never find that
out on your own.

On 18 Jun., 22:07, tobie <tobie.lan...@gmail.com> wrote:
> Sound like you're not setting up correct headers on your server.
>

> Have a look at this:http://en.wikipedia.org/wiki/XMLHTTP#Microsoft_Internet_Explorer_cach...

Francois

unread,
Jul 4, 2007, 3:05:09 AM7/4/07
to Ruby on Rails: Spinoffs
Hi,

I'm in the same fix. I read the wikipedia link above, but I didn't
understand how to relate that to code using Prototype. Could you
clarify what you have done to make your application work?

For reference, my code is:

<script type="text/javascript" language="javascript"
src="prototype.js"></script>
<script type="text/javascript" language="javascript">
obj = new Ajax.PeriodicalUpdater(
'sum_display',
'reader.php',
{
method: 'get',
parameters: {file : 'cache.html'},
frequency: 60
}
);
</script>

Where does the script described in the wikipedia page fit into that?

Thanks in advance for explanations

Gerrit

unread,
Jul 4, 2007, 7:59:42 AM7/4/07
to Ruby on Rails: Spinoffs
Hi Francois!
The Wikipedia page has been changed. Please have a look at the old
archived page:
http://en.wikipedia.org/w/index.php?title=XMLHttpRequest&oldid=141468975

Francois

unread,
Jul 9, 2007, 3:40:43 AM7/9/07
to Ruby on Rails: Spinoffs
Yes, that looks much clearer! Thanks a lot.

François

Reply all
Reply to author
Forward
0 new messages