Hi, I wonder if anyone could help:
I have the following functions set up to retrieve data from a php file:
[CODE]
function create_request_object()
{
var request_o;
var browser = navigator.appName;
if(browser == “Microsoft Internet Explorer”)
{
request_o = new ActiveXObject(“Microsoft.XMLHTTP”);
}
else
{
request_o = new XMLHttpRequest();
}
return request_o;
}
function get_value(req_url)
{
http.open(‘get’, req_url);
http.onreadystatechange = handle_data;
http.send(null);
}
function handle_data()
{
if(http.readyState == 4)
{
var response = http.responseText;
document.getElementById(content_container).innerHTML = response;
document.getElementById(content_container).style.display = ‘block’;
// hide any elements if requiured
for (i = 0; i < window.content_hide.length; i++)
{
document.getElementById(window.content_hide[i]).style.display = ‘none’;
}
// show any elements if requiured
for (i = 0; i < window.content_show.length; i++)
{
document.getElementById(window.content_show[i]).style.display = ‘block’;
}
}
}
I then call the functions later in the script
[CODE]
get_value(req_url);
This is probably really simple, but I just can’t get it to work. What I want, is for some way of knowing that response was populated and the html element was filled with it. Basically, I want a var set as true if everything worked. I have tried:
[CODE]
window.success = response;
But it is always undefined, even when the script has been successful. I hope I have explained well.
Thanks.