Question: I've trying to send some infromation to a php file and display the result returned. First of all I'm not receiving any results from php file i.e. no value in `xmlhttp.responseText`. Instead of responseText, I tried putting `'something else'` which made no difference. But when i comment out `//if (xmlhttp.readyState==4 && xmlhttp.status==200)`, the result briefly appears.
What have I done wrong?

Ajax code looks like this:

```
var div = 'display';
var xmlhttp;
if (window.XMLHttpRequest)
{
    xmlhttp=new XMLHttpRequest();
 }
else
{
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
        writeBack (div, xmlhttp.responseText+'something else', 'red');
    }
}

xmlhttp.open("POST","update_profile2.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("rr="+id);

```

Php code:

```
..
if(isset($_POST['rr']))
{
die('connection made');
}
..

```

Answer: 
Every problem I've ever had with AJAX is usually caused by trying to submit an AJAX request using a 'submit' button in a form. If you are doing that, make sure you stop the .submit() .... Also, if you use jQuery, your AJAX code will look sooooo much better :)
As others users say with jquery the code looks much better.

However I am quite sure your problem is with this line:

```
 xmlhttp.open("POST","update_profile2.php",true);

```

The request above access directly the update\_profile2.php and gets back the entire content of the php page, not the output elaborated by the page.
This is way you access the page without asking the web server (with the php engine) to serve it for you. And of course the http call fails so the condition && xmlhttp.status==200 blocks the execution of the next instruction that fills in the div.

use instead:

```
 xmlhttp.open("POST","http://localhost/update_profile2.php",true);

```

This will send a ajax http request to apache, il will run the php page and returns the answer of the page!