27.10.2015 Views

AJAX and PHP

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Client-Side Techniques with Smarter JavaScript<br />

// h<strong>and</strong>les the response received from the server<br />

function h<strong>and</strong>leServerResponse()<br />

{<br />

// read the message from the server<br />

var xmlResponse = xmlHttp.responseXML;<br />

// obtain the XML's document element<br />

xmlRoot = xmlResponse.documentElement;<br />

// obtain arrays with book titles <strong>and</strong> ISBNs<br />

titleArray = xmlRoot.getElementsByTagName("title");<br />

isbnArray = xmlRoot.getElementsByTagName("isbn");<br />

// generate HTML output<br />

var html = "";<br />

// iterate through the arrays <strong>and</strong> create an HTML structure<br />

for (var i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!