Hawkee commented on a Page, AJAX XMLHttp Request Aid  -  Sep 13, 2008

You don't really need to get xmlHttp every time an AJAX call is made. That can be done outside the function upon page load. I also think you should have done onreadystatechange to a function that handles the response, like this:

...
element = 'mydiv';
xmlHttp.onreadystatechange = handleResponse;
xmlHttp.send(null);

function handleResponse()
{
    if(xmlHttp.readyState == 4)
    {
        var response = xmlHttp.responseText;
        document.getElementById(element).innerHTML = response;
    }
}

This example will only work if xmlHttp and 'element' are declared globally.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.