27.10.2015 Views

AJAX and PHP

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>AJAX</strong> Real-Time Charting with SVG<br />

3. Then create a file named chart.svg, <strong>and</strong> add the following code to it:<br />

<br />

<br />

<br />

<br />

<br />

SVG with <strong>AJAX</strong> <strong>and</strong> <strong>PHP</strong> Demo<br />

<br />

<br />

<br />

4. Create a file named ajaxrequest.js with the following contents:<br />

// will store reference to the XMLHttpRequest object<br />

var xmlHttp = null;<br />

// creates an XMLHttpRequest instance<br />

function createXmlHttpRequestObject()<br />

{<br />

// will store the reference to the XMLHttpRequest object<br />

var xmlHttp;<br />

// this should work for all browsers except IE6 <strong>and</strong> older<br />

try<br />

{<br />

// try to create XMLHttpRequest object<br />

xmlHttp = new XMLHttpRequest();<br />

}<br />

catch(e)<br />

{<br />

// assume IE6 or older<br />

var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",<br />

"MSXML2.XMLHTTP.5.0",<br />

"MSXML2.XMLHTTP.4.0",<br />

"MSXML2.XMLHTTP.3.0",<br />

"MSXML2.XMLHTTP",<br />

"Microsoft.XMLHTTP");<br />

// try every prog id until one works<br />

for (var i=0; i

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

Saved successfully!

Ooh no, something went wrong!