SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    auto refresh a particular div

    how can i auto refresh the div in a particular page

  2. #2
    Non-Member
    Join Date
    Oct 2007
    Posts
    363
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    You can update individual parts of a page without refreshing the rest of the page using javascript/Ajax.

    If you want to auto refresh it, you can just create a timed loop in javascript. There's a function called setInterval() that allows you to do something like this.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're using jQuery:
    Code:
    setInterval(function() {
        $("#refresh").load(location.href+" #refresh>*","");
    }, 10000); // seconds to wait, miliseconds
    where #refresh is the element you want to refresh.
    Martin.

  4. #4
    Non-Member
    Join Date
    Oct 2007
    Posts
    363
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Yeah mart - but that's actually using jquery, not pure javascript.

    In order for the above code to work, you'll need to include the jquery library.

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by aaarrrggh View Post
    Yeah mart - but that's actually using jquery, not pure javascript.
    Yes, that's why I said "If you're using jQuery".
    Martin.

  6. #6
    Non-Member
    Join Date
    Oct 2007
    Posts
    363
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by martbean View Post
    Yes, that's why I said "If you're using jQuery".
    lol doh...

    Must have been half asleep, because I missed that


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
  •