Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2007, 10:55 AM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is readyState always 1? sqad Ajax 5 April 29th, 2008 07:35 PM
readyState won't move from 1 to 2! lmireskandari Javascript 0 February 28th, 2007 11:50 AM
readyState not ready -- closed see google groups scottradny BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 March 30th, 2006 11:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.