This test uses 3 xHttpRequest objects. Test 1 uses one xHttpRequest object.
You can run each demo individually or run them all at once.
This demo uses responseText.
This demo uses responseXML. It uses xWalkTree to easily parse the received XML.
This demo is just like demo 2 except this one receives XML which is more deeply nested. It doesn't matter how deeply nested the XML is - just specify the nodeNames you're looking for and call xParseXml.
This runs all 3 demos.
This is the PHP file to which demo 1 makes its requests.
<?php if (count($_POST)) { echo $_POST['v1']; echo $_POST['v2']; echo $_POST['v3']; echo '<p>' . $_POST['rnd'] . '</p>'; } else if (count($_GET)) { echo $_GET['v1']; echo $_GET['v2']; echo $_GET['v3']; echo '<p>' . $_GET['rnd'] . '</p>'; } ?>
This is the PHP file to which demo 2 makes its requests.
<?php header('Content-type: text/xml'); ?> <parent> <child> <gc1>c1 gc1 - text</gc1> <gc2><![CDATA[c1 gc2 - cdata]]></gc2> </child> <child> <gc1>c2 gc1 - text</gc1> <gc2><![CDATA[c2 gc2 - cdata]]></gc2> </child> <child> <gc1>c3 gc1 - text</gc1> <gc2><![CDATA[c3 gc2 - cdata]]></gc2> </child> <child> <gc1>c4 gc1 - text (<?php echo $_GET['rnd'] ?>)</gc1> <gc2><![CDATA[c4 gc2 - cdata (<?php echo rand() ?>)]]></gc2> </child> </parent>
This is the PHP file to which demo 3 makes its requests.
<?php header('Content-type: text/xml'); ?> <parent> <child> <gc> <ggc1>c1 gc1 ggc1 - text</ggc1> <ggc2><![CDATA[c1 gc1 ggc2 - cdata]]></ggc2> </gc> <gc> <ggc1>c1 gc2 ggc1 - text</ggc1> <ggc2><![CDATA[c1 gc2 ggc2 - cdata]]></ggc2> </gc> </child> <child> <gc> <ggc1>c2 gc1 ggc1 - text</ggc1> <ggc2><![CDATA[c2 gc1 ggc2 - cdata]]></ggc2> </gc> <gc> <ggc1>c2 gc2 ggc1 - text (<?php echo $_GET['rnd'] ?>)</ggc1> <ggc2><![CDATA[c2 gc2 ggc2 - cdata (<?php echo rand() ?>)]]></ggc2> </gc> </child> </parent>
Simple experiments with the XMLHttpRequest object.
View the source and documentation for xHttpRequest.
These demos also make good use of xWalkTree in parsing the returned XML.