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 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Periodic Div refresh

    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

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    You're correct, it's fairly easy to use setTimeout w/AJAX. Here is an example: http://www.openhosting.co.uk/articles/webdev/6004/

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    Last edited by yvorl; 10-12-2007 at 08:05 AM.

  • #4
    New Coder
    Join Date
    Oct 2007
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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):

    Code:
    <?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.
    Last edited by yvorl; 10-12-2007 at 08:56 AM.


  •  

    Posting Permissions

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