server has PHP 5 "!I wrote a version that only uses Javascript http://www.w3schools.com/php/php_ajax_xml.asp http://webspace.cs.odu.edu/~mweigle/cs312/php5/plants.html http://www.cs.odu.edu/~mweigle/cs312/php/plants.html 4 AJAX XML plants.html
Plant info will be listed here.
5 AJAX XML selectPlant.js var xmlHttp; function showPlant(str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="getPlant.php"; url=url+"?q="+str; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } 6 AJAX XML selectPlant.js function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } } 7 AJAX XML selectPlant.js function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } 8 plant_catalog.xml CATALOG PLANT COMMON BOTANICAL ZONE LIGHT PRICE AVAILABILITY 9 AJAX XML getPlant.php load("../xml/plant_catalog.xml"); $x = $xmlDoc->getElementsByTagName ('COMMON'); for ($i=0; $i<=$x->length-1; $i++) { // Process only element nodes if ($x->item($i)->nodeType == 1) { if ($x->item($i)->childNodes->item(0)->nodeValue == $q) { $y = ($x->item($i)->parentNode); } } } not supported...Website: www.cs.odu.edu | Filesize: 250kb
No of Page(s): 30
Download Web Programming/Scripting: AJAX Examples and Google Maps API.pdf
No comments:
Post a Comment