SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist webchalkboard's Avatar
    Join Date
    Jan 2005
    Location
    Bristol, UK
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto Refreshing Page Content with Javascript

    Hi,

    I'm just wondering how I can auto-refresh the content on my page without doing a full page reload? I know you can use jQuery AJAX to do this quite easily, but how can I loop to call this code every 10 seconds or so?

    I have a cron script you see that sends out emails, and I want to watch a counter go up on my page showing how many emails have been sent, without actually having to refresh the whole page every couple of seconds.

    I know this is possible, but I'm not sure the best approach to take.

    Many thanks in anticipation!

    Tom
    Websites for Sale - Sell websites in a purpose built marketplace
    Then do some Shopping

  2. #2
    SitePoint Evangelist webchalkboard's Avatar
    Join Date
    Jan 2005
    Location
    Bristol, UK
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok this is what I'm trying to do...

    http://www.openhosting.co.uk/articles/webdev/6004/

    edit - Problem solved and it works very nicely too - jQuery makes it even easier than in that article just for anyone else's reference who finds this.
    Websites for Sale - Sell websites in a purpose built marketplace
    Then do some Shopping

  3. #3
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,880
    Mentioned
    48 Post(s)
    Tagged
    0 Thread(s)
    Just create a function called getContent() or something.

    Then on page load wen the dom is ready call the getContent function. At the end of the function put this: setTimeout('getContent()', 60000);

    This will run that function every 60 secs or 1 minute

  4. #4
    SitePoint Evangelist webchalkboard's Avatar
    Join Date
    Jan 2005
    Location
    Bristol, UK
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah cool thanks that works great.
    Websites for Sale - Sell websites in a purpose built marketplace
    Then do some Shopping


Bookmarks

Posting Permissions

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