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.

header('Expires: Fri, 25 Dec 1980 00:00:00 GMT'); // time in the past<br />

header('Last-Modified: ' . gmdate( 'D, d M Y H:i:s') . 'GMT');<br />

header('Cache-Control: no-cache, must-revalidate');<br />

header('Pragma: no-cache');<br />

header('Content-Type: text/html');<br />

// execute the client request <strong>and</strong> return the updated tasks list<br />

echo $myTasksList->Process($content, $action);<br />

?><br />

9. Create a new file named drag-<strong>and</strong>-drop.js, <strong>and</strong> add this code to it:<br />

// holds an instance of XMLHttpRequest<br />

var xmlHttp = createXmlHttpRequestObject();<br />

// when set to true, display detailed error messages<br />

var showErrors = true;<br />

// initialize the requests cache<br />

var cache = new Array();<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!