11.07.2015 Views

AJAX and PHP

AJAX and PHP

AJAX and PHP

SHOW MORE
SHOW LESS

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

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

This example requires a JavaScript-enabled browser!Welcome to <strong>AJAX</strong> Friendly!Your news for today:4. Add a new file named friendly.css:body{font-family: Arial, Helvetica, sans-serif;font-size: small;background-color: #fffccc;}input{margin-bottom: 3px;border: #000099 1px solid;}.title{font-size: x-large;}div.project{background-color: #99ccff;padding: 5px;border: #000099 1px solid;}div.news{background-color: #fffbb8;padding: 2px;border: 1px dashed;}5. Now add the JavaScript source file, friendly.js:// holds an instance of XMLHttpRequestvar xmlHttp = createXmlHttpRequestObject();// holds the remote server address <strong>and</strong> parametersvar serverAddress = "friendly.php?action=GetNews";// variables that establish how often to access the servervar updateInterval = 5; // how many seconds to wait to get new messagevar errorRetryInterval = 30; // seconds to wait after server error// when set to true, display detailed error messagesvar debugMode = true;Chapter 3113

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

Saved successfully!

Ooh no, something went wrong!