The page on the server called by the JavaScript is a PHP file called
Course information will be listed here.
GetCourse.php
as below, which loads an XML document, CourseList.xml
, runs a query against the XML file, and returns the result as HTML.
When the course query is sent from the JavaScript to the PHP page, the following happens:
number
element that matches the course number sent from the JavaScript.
txtHint
placeholder)
<?php $q = $_GET["q"]; $xmlDoc = new DOMDocument( ); $xmlDoc->load( "CourseList.xml" ); $x = $xmlDoc->getElementsByTagName( 'number' ); for ( $i=0; $i<=$x->length-1; $i++ ) { // Process only element nodes. if ( $x->item($i)->nodeType == 1 ) { // 1: element if ( $x->item($i)->childNodes->item(0)->nodeValue == $q ) { $y = ( $x->item($i)->parentNode ); } } } $course = ( $y->childNodes ); for ( $i=0; $i<$course->length; $i++ ) { // Process only element nodes. if ( $course->item($i)->nodeType == 1 ) { echo( $course->item($i)->nodeName . ":" ); echo( $course->item($i)->childNodes->item(0)->nodeValue ); } } ?> |
I’m sick of following my dreams —
I’m just going to ask them where they are going and hook up with them later. — Natasha Leggero |