Hi there, I'm trying to do an asynchrynous request to a php page and then update a div with the contents. I've done this sucessfully in the past but this script is driving me insane! Where should I place the onreadystatechange method in this script please:
I've tried it before and after the send but it either doesn't work, or only works the second time the function is called.
Thanks
Gary
-Geeeeeeeeeeeeeeeeeeeeeeee-
-=
Code:
var http = getHTTPObject();
var url = 'js/clevertext.php';
function updatetext($field, $client_id) {
http.open("GET", url, true);
http.send(null);
http.onreadystatechange = handleStateChange();
}
function handleStateChange() {
if (http.readyState == 4) {
alert(http.responseText);
}
}
function getHTTPObject() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try
{
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
I've tried it before and after the send but it either doesn't work, or only works the second time the function is called.
Thanks
Gary
-Geeeeeeeeeeeeeeeeeeeeeeee-
-=