The Entry Point
The entry point to the aggregator is the index.html file, which we call from the browser. Here’s the code that represents the index:
<html> <head> <title>RSS Aggregation with PHP and Ajax</title> <link href="css/layout.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/model/HTTP.js"></script> <script type="text/javascript" src="js/model/Ajax.js"></script> <script type="text/javascript" src="js/model/AjaxUpdater.js"></script> <script type="text/javascript" src="js/controller/Aggregator.js"></script> <script type="text/javascript" src="js/view/Feed.js"></script> </head> <body> <div id="Aggregator"> <form name="feedForm" method="post" action="javascript:AjaxUpdater.Update(’GET’, ’bridge/rss.php?feed=’ + document.feedForm.feed.value, Aggregator.Read);"> <div class="header"> <input type="text" name="feed" id="feed" size="50"> <input type="submit" name="submit" value="Add Feed"> </div> </form> <div class="leftColumn"> <div id="titles"></div> <div id="loading"></div> </div> <div class="rightColumn"> <div id="description"></div> </div> </div> </body> </html>
This file imports the CSS file that will handle the display of our aggregator and all of the JavaScript files that we’ll use to create the aggregator and make the AJAX requests.
The index then defines the DIV tags, which will represent the layout of the data when it’s received. It also contains a form that has an input field for entering URLs of RSS feeds and a submit button for sending requests to them. When the button is clicked, a request will be made to receive that RSS feed and send the response to an object called Aggregator, which we’ll cover after we focus on the retrieval of remote RSS feeds with AJAX.