Hello,
I am trying to write a simple AJAX program that alerts the parameters passed to the server.
JS:
http = new XMLHttpRequest();
http.onreadystatechange = function()
{
if (http.readyState==4 && http.status==200)
{
alert(http.responseText);
}
};
function post()
{
http.open("POST", "http://url.com/get.php", true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.send("number=100");
};
post();
get.php:
<?php
echo $_POST['number'];
?>
When I run this program nothing shows up…
What am I doing wrong?
Thanks!
Also if I add a tracer in the onreadystatechange fucntion the readyState goes from 2 to 4 but the status stays at 0.
And I just thought of it, but I am opening the html page from my local computer.