Datasheet
Content-Length: 831
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”?>
<watches><watch><symbol>cce</symbol><tag>coke</tag><title>Coca
Cola</title><description>Find their secret...</description></watch>
<watch><symbol>goog</symbol><tag>google</tag><title>Google</title><description>If
you don’t know them, google them!</description></watch>
<watch><symbol>ibm</symbol><tag>ibm</tag><title>IBM</title><description>Big
blue...</description></watch>
<watch><symbol>jw-a</symbol><tag>wiley</tag><title>Wiley</title><description>Our
publisher.</description></watch>
<watch><symbol>msft</symbol><tag>microsoft</tag><title>Microsoft</title>
<description>The company we love to hate.</description></watch>
<watch><symbol>wmt</symbol><tag>walmart</tag><title>Walmart
stores</title><description>You can’t be number one and have only
friends...</description></watch>
</watches>
After this small incursion into PHP land, you need to switch back to JavaScript. When this response
reaches the browser, the YUI calls back the
handleListSuccess method in controller.js as
instructed:
BuzzWatchController.prototype.handleListSuccess = function(o) {
if(o.responseText !== undefined){
this.setTimeout(getMaxAge(o));
var xotree = new XML.ObjTree();
xotree.force_array = [“watch”];
var tree = xotree.parseDOM( o.responseXML.documentElement );
var menu = YAHOO.buzzWatch.menuGo.cfg.getProperty(“submenu”);
while (menu.getItemGroups().length > 0) {
var menuItem = menu.removeItem(0);
menuItem.destroy();
}
var watches = tree.watches.watch;
for (var i=0; i< watches.length; i++) {
var watch = watches[i];
var menuItem = new YAHOO.widget.MenuItem(
watch.title + ‘ (‘ + watch.symbol+’)’,
{}
);
menu.addItem(menuItem);
menuItem.clickEvent.subscribe(
this.loadSymbol,
watch.symbol,
false
);
}
menu.render();
}
}
15
Hello Web 2.0 World
04_087889 ch01.qxp 5/2/07 12:56 PM Page 15