Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 7 of 7

Thread: ajax

  1. #1
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default ajax

    anyone know how to make a page (txt page) reload every so many seconds without refreshing the page.. mentor made one awhile ago but it doesn't work.

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  2. #2
    Join Date
    Mar 2005
    Location
    Leeds
    Posts
    3,423
    Tokens
    0

    Latest Awards:

    Default

    try using script.aculo.us

  3. #3
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Colin-Roberts View Post
    anyone know how to make a page (txt page) reload every so many seconds without refreshing the page.. mentor made one awhile ago but it doesn't work.
    Im pretty sure the script did work by the end of it? although i finalized outside forums. Its pretty simple to do without even changing the function anyway:


    Heres a quick usage of my ajax page loading script to acheave the desired effect

    Code:
    // sets time between reloads in miliseconds
    setInterval(LoadPage("INFOFILE.php","DIVNAME"), 30000);
    
    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.");}
             //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);
    }
    Only change from orignal is use of interval function to call it every so often.

    Just chnage INFOFILE.php to the file name of the page you want to load from, and DIVNAME to the ID of the div you want to place the content returned in.

    *other none essental changes made.
    Removed, return false as served no purpous. Scroll to top, becuse it would be annoying, and page loading message since it would be in the way alot

    Easy as pie
    Last edited by Mentor; 02-06-2007 at 10:54 PM.

  4. #4
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default

    thanx mentor. still isn't working for me?
    Last edited by Colin-Roberts; 02-06-2007 at 11:35 PM.

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  5. #5
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    in the example it refresh's every 30 seconds, so you may need to make it shorter interval?
    The code itself though should work? What JS errors is it giveing you?

  6. #6
    Join Date
    Feb 2006
    Location
    Ontario Canada
    Posts
    4,587
    Tokens
    0

    Latest Awards:

    Default

    it isnt erroring out anything it just leaves my div blank and loads nothing

    .:.:#14:.:. .:.: Impossible Is Nothing :.:. .:.: 845 Rep:.:.
    .:.: Stand up for what is right, even if you stand alone:.:.


  7. #7
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Quote Originally Posted by Colin-Roberts View Post
    it isnt erroring out anything it just leaves my div blank and loads nothing
    To make a default page load on startup, put:

    <body onload="LoadPage('page2.htm','page_content');">

Posting Permissions

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