Source for file xml_usage.php
Documentation is available at xml_usage.php
* Example of Using HTML_AJAX in proxy operation
* All AJAX calls are handled by the xmlserver.php
* The only needed interaction is creation of a new object from the proxy defintion, all AJAX calls happen transparently from there
* If you want to perform async calls a callback object must be passed to the constructor of the object
* @author Elizabeth Smith <auroraeosrose@gmail.com>
* @copyright 2006 Elizabeth Smith
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version Release: 0.5.4
* @link http://pear.php.net/package/HTML_AJAX
<script type='text/javascript' src="xmlserver.php?client=all"></script>
<script type='text/javascript' src="xmlserver.php?stub=testxml"></script>
<script type='text/javascript'>
// function to display xml received from server
var list=xml.getElementsByTagName('item');
document.getElementById('target').innerHTML = '<p>My Fridge</p>';
for (var i=0;i<list.length;i++)
document.getElementById('target').innerHTML += '<p>' + node.firstChild.nodeValue
+ ' is a ' + node.getAttribute('type') + '</p>';
// function to display xml created here
function showMessage(xml)
var list=xml.getElementsByTagName('tag');
document.getElementById('target').innerHTML = '';
for (var i=0;i<list.length;i++)
document.getElementById('target').innerHTML += '<p>' + node.firstChild.nodeValue + '</p>';
// definition of the callback javascript class, used to handle async requests
createJunk: function(result) {
writeDoc: function(result) {
dom = HTML_AJAX.grab('test.xml');
// function used to clear out the target div
document.getElementById('target').innerHTML = 'clear';
//create xml document to send back to server
var xmlhello = '<' + '?xml version="1.0"?><root><tag>Hello</tag></root>';
xmlhello = new DOMParser().parseFromString(xmlhello, 'text/xml');
var xmlgoodbye = '<' + '?xml version="1.0"?><root><tag>Goodbye</tag></root>';
xmlgoodbye = new DOMParser().parseFromString(xmlgoodbye, 'text/xml');
<script type="text/javascript">
// create a proxy in sync mode
var syncProxy = new TestXml();
// create a proxy in async mode
var asyncProxy = new TestXml(new callback());
// run a sync call and set its results to the target div
dom = syncProxy.createHealthy();
dom = HTML_AJAX.grab('test.xml');
// run a sync call, callback class will handle its results
// run a sync call, callback class will handle its results
function asyncSend(xml) {
asyncProxy.writeDoc(xml);
<p>HTML_AJAX XML functionality needs the Dom extensions in PHP5 or the DOMXML extension in PHP4.<br>
It looks like you have:<br>
echo 'The Dom extension';
echo 'The Domxml extension';
echo 'No XML DOM support, so you can expect these examples to fail';
<li><a href="javascript:clearTarget()">Clear Target</a></li>
<li><a href="javascript:syncCall()">Retrieve XmlDom Sync</a></li>
<li><a href="javascript:asyncCall();">Retrieve XmlDom Async</a></li>
<li><a href="javascript:syncSend(xmlhello);">Send XmlDom Sync</a></li>
<li><a href="javascript:asyncSend(xmlgoodbye);">Send XmlDom Async</a></li>
<div style="white-space: pre; padding: 1em; margin: 1em; width: 600px; height: 300px; border: solid 2px black; overflow: auto;" id="target">Target</div>
Documentation generated on Fri, 04 Apr 2008 18:30:28 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|