PDA

View Full Version : JS Help!



Invent
28-05-2007, 08:39 PM
Hey,

I need some JS help for the myHABBO Homes script.

I have 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>I have a working xmlHttp function, does anyone know why it's not working?

Drompo
28-05-2007, 08:52 PM
I can't see anything.

Also Release the etire script when complete

Invent
28-05-2007, 08:53 PM
No.

My script will never be released.x

Mentor
28-05-2007, 09:05 PM
are you geting any JS error? it could just be the php handler is fecking up and not sending back the right stuff even?

btw, u dont need a ; on the end of a function, the "};" should be just "}"

Invent
28-05-2007, 09:06 PM
It's not doing anything :p

All I've got in the PHP file is:



<?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 :(

Mentor
28-05-2007, 09:07 PM
It's not doing anything :p

All I've got in the PHP file is:



<?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

Invent
28-05-2007, 09:09 PM
Sorry, the file does exist.

Splinter
28-05-2007, 10:07 PM
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

Heinous
29-05-2007, 11:05 AM
Try this;


<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>

Want to hide these adverts? Register an account for free!