# AJAX POST n00b Problem

**URL:** <https://forum.kirupa.com/t/ajax-post-n00b-problem/311676>\
**Category:** programming\
**Created:** [July 14, 2010, 1:26am UTC](https://forum.kirupa.com/t/ajax-post-n00b-problem/311676 "2010-07-14T01:26:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick23](https://avatars.discourse-cdn.com/v4/letter/n/76d3ee/32.png) [@Nick23](https://forum.kirupa.com/u/Nick23)\
**Post date:** [July 14, 2010, 1:26am UTC](https://forum.kirupa.com/t/ajax-post-n00b-problem/311676/1 "2010-07-14T01:26:56Z")

</div>

Hello,  
I am trying to write a simple AJAX program that alerts the parameters passed to the server.

JS:

```auto

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:

```auto

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