Always getting readyState = 1
I have the following Javascript code that fills an array in a PHP doc:
function getOptions(scheme)
{
var url = "options.php?scheme=" + scheme;
if (xmlHttpObj)
{
xmlHttpObj.open("GET", url, true);
xmlHttpObj.onreadystatechange=function()
{
if (xmlHttpObj.readyState == 4 &&
xmlHttpObj.status == 200 || xmlHttpObj.status == 304)
{
var xmlDocument = xmlHttpObj.responseXML;
options = xmlDocument.getElementsByTagName("option");
listOptions();
}
}
xmlHttpObj.send(null);
}
}
The php looks like this:
<?
header("Content-type: text/xml");
if ($_GET["scheme"] == "1")
$options = array('red', 'green', 'blue');
if ($_GET["scheme"] == "2")
$options = array('black', 'white', 'orange');
echo '<?xml version="1.0"?>';
echo '<options>';
foreach ($options as $value)
{
echo '<option>';
echo $value;
echo '</option>';
}
echo '</options>;
?>
I call the function OK, but always get a readyState of 1.
Any ideas anyone?
|