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.

Chapter 9<br />

}<br />

width: 410px;<br />

background-color: #fffbb8;<br />

color: #FF9900;<br />

border: 1px solid #ffcc00;<br />

font-weight: bold;<br />

.date<br />

{<br />

font-size: 10px;<br />

color: #999999;<br />

}<br />

10. Load http://localhost/ajax/rss_reader in your web browser. The initial page<br />

should look like Figure 9.3. If you click one of the links, you should get something<br />

like Figure 9.2.<br />

Figure 9.3: The First Page of the <strong>AJAX</strong> RSS Reader<br />

What Just Happened?<br />

It's not a really professional application at this state, but the point is proven. It doesn't take much<br />

code to accomplish such a result <strong>and</strong> any features you might think of can be added easily.<br />

The user interface of this application is pretty basic, all set up in index.php. We first need to<br />

include config.php—where our feeds are defined, in order to display the list of feeds on the left<br />

panel. Feeds are defined as an associative array of arrays. The main array's keys are numbers<br />

starting from 0 <strong>and</strong> its values are arrays, with keys being the feeds' titles <strong>and</strong> values being the<br />

feeds' URLs. The $feeds array looks like this:<br />

$feeds = array ("0" => array("title" => "CNN Technology",<br />

"feed" => "http://rss.cnn.com/rss/cnn_tech.rss"),<br />

233<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!