...

Periodic Div refresh

yvorl
10-12-2007, 07:18 AM
Hi!

I know it sounds so simple, but i'm new to ajax and i'm just not able to get on with this. The problem: There is a file (txt) on the server. I'd like to display the content of this file in a div and update it dinamically in every x seconds because the content of the txt is changing. I'd like it to work of corse under ie,firefox,etc..

I probably need an XMLHttpRequest, a setTimeout but i just can't make it to work right and periodically. It shouldn't be so hard to do i guess.

Can anyone help me?

Thx

Inigoesdr
10-12-2007, 07:23 AM
You're correct, it's fairly easy to use setTimeout w/AJAX. Here is an example: http://www.openhosting.co.uk/articles/webdev/6004/

yvorl
10-12-2007, 07:44 AM
I've checked the example, but i just can't run asp file on the server. I guess it can be anything, even a txt, or a php that reads and displays the txt, but it's not working for me like that..i don't know why.
And in this case, what about the ie cache problem?

yvorl
10-12-2007, 08:41 AM
So it seems the problem is finally solved. I used the script from
http://www.openhosting.co.uk/articles/webdev/6004/

to the top i've put: var page = "something.php";

to avoid ie cache problem, i'put this into something.php (probably one of them is enough, 'cos these are redundant):


<?php
header( 'Cache-control: no-cache' );
header( 'Cache-control: no-store' );
header( 'Pragma: no-cache' );
header( 'Expires: 0' );
..
rest of the code
...
?>


Probably it can be more elegant, but it's just working.Maybe it can help someone with the same problem.

Thx for the help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum