Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default Ajax script needed

    need a way to refresh a div every 20 seconds :S it is possible ive seen the script where abouts before but cannot re find it +rep for all help
    ive found a way round using iframes at last

  2. #2
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default

    I have typed getting some thing like this but when i tryed it did not work and i have ask on many forum so i would like some thing like this to so i do hope some one can help Eccentric and me to

  3. #3
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    Lol i cant remember wher i saw it :S

  4. #4
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Make a function which loads the html into the DIV.

    Then just use setInterval() to make it run the function every 20 seconds.

  5. #5
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    right simon,
    i have this so far,
    Code:
    function LoadPage(page,usediv) {
            // Set up request varible
            try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");}  catch (e) { alert("Error: Could not load page.");}
            //Show page is loading
            document.getElementById(usediv).innerHTML = 'Loading Page...';
            //scroll to top
            scroll(0,0);
            //send data
            xmlhttp.onreadystatechange = function(){
                    //Check page is completed and there were no problems.
                    if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
                           //Write data returned to page
                           document.getElementById(usediv).innerHTML = xmlhttp.responseText;
                    }
            }
            xmlhttp.open("GET", page);
            xmlhttp.send(null);
            //Stop any link loading normaly
    }
    what do i do now

  6. #6
    Join Date
    Aug 2007
    Posts
    204
    Tokens
    0

    Default

    put it in your source web page

  7. #7
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    function LoadPage(page,usediv) {
    // Set up request varible
    try {xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { alert("Error: Could not load page.");}
    //Show page is loading
    document.getElementById(usediv).innerHTML = 'Loading Page...';
    //scroll to top
    scroll(0,0);
    //send data
    xmlhttp.onreadystatechange = function(){
    //Check page is completed and there were no problems.
    if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
    //Write data returned to page
    document.getElementById(usediv).innerHTML = xmlhttp.responseText;
    }
    }
    xmlhttp.open("GET", page);
    xmlhttp.send(null);
    //Stop any link loading normaly
    }
    setInterval('LoadPage()', 2000);


    i know have that but i believe it isnt working

  8. #8
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Change:
    setInterval('LoadPage()', 2000);

    To:
    setInterval('LoadPage("thepageyouwanttoload.php", "div you want the page to show in")', 2000);

  9. #9
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    Thanks si, ill try that now.
    Edit;
    Simon you are a star my friend. +rep ! need to spread to be honest :|
    Last edited by Eccentric; 15-09-2007 at 04:29 PM.

  10. #10
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    UPDATE:
    i know see double of everything its to do with that piece of ajax :|

Page 1 of 2 12 LastLast

Posting Permissions

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