Results 1 to 9 of 9

Thread: JS Help!

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

    Latest Awards:

    Default JS Help!

    Hey,

    I need some JS help for the myHABBO Homes script.

    I have this code:

    HTML Code:
    <script type="text/javascript">
    <!--
    function save() {
    
    xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object.
    if (xmlHttp==null){ // If it cannot create a new Xmlhttp object.
    alert ("Browser does not support HTTP Request") // Alert Them!
    return // Returns.
    } // End If.
    
    
    var sticker_cactus_1_yuh = "lol"
    
    var url="update.php?update=true&"+sticker_cactus_1="+sticker_cactus_1_yuh
    
    xmlHttp.open("GET",url,true) // Opens the URL using GET
    xmlHttp.onreadystatechange = function () { // This is the most important piece of the puzzle, if onreadystatechange is equal to 4 than that means the request is done.
    if (xmlHttp.readyState == 4) { // If the onreadystatechange is equal to 4 lets show the response text.
    document.getElementById("update").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php
    } // End If.
    }; // Close Function
    xmlHttp.send(null); // Sends NULL instead of sending data.
    } // Close Function.
    
    
    -->
    
    </script>
    I have a working xmlHttp function, does anyone know why it's not working?
    Last edited by Invent; 28-05-2007 at 08:42 PM.

  2. #2
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default

    I can't see anything.

    Also Release the etire script when complete


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

    Latest Awards:

    Default

    No.

    My script will never be released.x

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

    Latest Awards:

    Default

    are you geting any JS error? it could just be the php handler is ****ing up and not sending back the right stuff even?

    btw, u dont need a ; on the end of a function, the "};" should be just "}"
    Last edited by Mentor; 28-05-2007 at 09:06 PM.

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

    Latest Awards:

    Default

    It's not doing anything :p

    All I've got in the PHP file is:

    PHP Code:
    <?php

    if($_GET['update'] == "true") {

    $k fopen("lol.txt""w");

    fwrite($k"lols!");

    fclose($k);
    }

    ?>
    So that I know the function is working.

    But no file is being written

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

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    It's not doing anything :p

    All I've got in the PHP file is:

    PHP Code:
    <?php

    if($_GET['update'] == "true") {

    $k fopen("lol.txt""w");

    fwrite($k"lols!");

    fclose($k);
    }

    ?>
    So that I know the function is working.

    But no file is being written
    if u want it to create a new file u need to use w+, w will only write to a pre existing file

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

    Latest Awards:

    Default

    Sorry, the file does exist.

  8. #8
    Join Date
    Nov 2005
    Posts
    807
    Tokens
    1,335

    Latest Awards:

    Default

    What browser are you viewing this in?
    If firefox use the javascript console and see if there are any errors.

    Also this looks wrong:
    var url="update.php?update=true&"+sticker_cactus_1="+sticker_cactus_1_yuh
    Make it:
    var url="update.php?update=true&sticker_cactus_1="+sticker_cactus_1_yuh
    Last edited by Splinter; 28-05-2007 at 10:10 PM.

  9. #9
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Try this;

    Code:
    <script type="text/javascript">
    <!--
    function save()
    	{
    		xmlHttp = GetXmlHttpObject; // Creates a new Xmlhttp object.
    		if (xmlHttp==null)
    			{ // If it cannot create a new Xmlhttp object.
    				alert ("Browser does not support HTTP Request"); // Alert Them!
    				return; // Returns.
    			} // End If.
    		var sticker_cactus_1_yuh = "lol";
    		var url="update.php?update=true&"+sticker_cactus_1="+sticker_cactus_1_yuh";
    		xmlHttp.open("GET",url,true); // Opens the URL using GET
    		xmlHttp.onreadystatechange = function () 
    			{ // This is the most important piece of the puzzle, if onreadystatechange is equal to 4 than that means the request is done.
    				if (xmlHttp.readyState == 4)
    					{ // If the onreadystatechange is equal to 4 lets show the response text.
    						document.getElementById("update").innerHTML = xmlHttp.responseText; // Updates the div with the response text from check.php
    					} // End If.
    			} // Close Function
    	xmlHttp.send(null); // Sends NULL instead of sending data.
    	} // Close Function.
    -->
    </script>
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

Posting Permissions

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