Datasheet

The HTTP answer to this request is:
HTTP/1.1 200 OK
Date: Sat, 22 Jul 2006 10:18:32 GMT
Server: Apache/2.0.55 (Ubuntu) PHP/5.1.2
X-Powered-By: PHP/5.1.2
Cache-Control: max-age=60
Content-Length: 152
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/xml
X-Pad: avoid browser bug
<?xml version=”1.0” encoding=”utf-8”?><watch>
<symbol>jw-a</symbol><tag>wiley</tag><title>Wiley</title>
<description>Our publisher.</description></watch>
Back to JavaScript. When the browser receives this answer, the YUI fires the callback routine in
controller.js that has been set up in case of success:
BuzzWatchController.prototype.handleSuccess = function(o) {
if(o.responseText !== undefined){
var xotree = new XML.ObjTree();
var tree = xotree.parseDOM( o.responseXML.documentElement );
YAHOO.buzzWatch.config.set(tree.watch.symbol, tree.watch.tag);
refreshPanels();
YAHOO.buzzWatch.editInPlace.set(‘textTitle’, tree.watch.title);
YAHOO.buzzWatch.editInPlace.set(‘textDescription’, tree.watch.description);
}
This method relies again on the JKL.ParseXML library to manipulate the XML document that has
JavaScript objects. It sets the symbol and tag attributes that are handled by another object, the
YAHOO
.buzzWatch.config
object, refreshes the panels, and sets the title and description. The rest of the appli-
cation is quite similar to what you’ve already seen. The
refreshPanels method, for example, uses the
YAHOO.util.Connect.asyncRequest method to fetch the XML information that is displayed in the
panels. You now have a good idea of what’s going on behind the scene to skip the rest of the detailed
technical description of BuzzWatch, but there are a couple of questions that are still worth answering:
Why does BuzzWatch have to cache the content that is aggregated? And how do you save watches into
the database?
The server’s log shows that, instead of retrieving aggregated data directly from the browser and down-
load, for example, the RSS channel
http://del.icio.us/rss/tag/wiley directly from del.icio.us,
the browser fetches a cached copy on the BuzzWatch server (that’s the line with
GET /buzzwatch/
delicious.php?tag=wiley
). There are several reasons for that; the most important reason is that the
browser would refuse to retrieve the RSS channel directly from del.icio.us and would raise an exception
saying that your script isn’t authorized to do so. Although you could find this restriction painful and
pointless in that specific case (what harm is there in accessing public data from JavaScript?), this restric-
tion is much needed to avoid allowing a script to access private information available to the browser.
Without this restriction, a script executed from the public web could access and steal private information
available behind a firewall or through the user’s credentials.
19
Hello Web 2.0 World
04_087889 ch01.qxp 5/2/07 12:56 PM Page 19