- Ways to see the difference between AJAX and non-AJAX apps
- Different AJAX libraries
- YUI
- How to learn YUI
- Good references
Roughly speaking, AJAX is aimed at making web apps more like desktop apps. What do we mean by this?
Ways to see the difference between AJAX and non-AJAX apps
-
turn of Javascript in your browser and see what happens to
flickr and mapping applications and Gmail.
-
In Flickr, look at how (for instance):
-
titles, descriptions, tags get changed
-
pictures get submitted to groups
-
Notice that some apps will gracefully support non-Javascript enabled browsers. (Interesting and important issues around usability/accessibility)
Different AJAX libraries
-
I will demo the
Yahoo! UI Library. There are plenty of alternatives, including:
-
For a bigger list, see
Ajax Design Patterns (subscription only)
YUI
-
outline embedded in TreeView. Code:
<html>
<head>
<script src = "../yui/treeview/examples/js/YAHOO.js" ></script>
<script src = "../yui/treeview/examples/js/treeview.js" ></script>
<link rel="stylesheet" type="text/css" href="../yui/treeview/examples/css/screen.css">
<link rel="stylesheet" type="text/css" href="../yui/treeview/examples/css/default/tree.css">
</head>
<body onload="treeInit()">
<div id='treeDiv1'></div>
<script>
//var outline = eval({"text":"testing", "o":[{"text":"say \"hi\". I\'m here."}, {"text":"json"}]});
var outline = eval({"text":"YUI", "o":[{"text":"documentation and background", "o":[{"text":"[http://developer.yahoo.net/yui/#download Yahoo! UI Library]"}, "text":"[http://simon.incutio.com/archive/2006/02/14/ui Simon Willison: Yahoo! UI JavaScript treats]"}, {"text":"file:///d:/document/lib/yui/"}, {"text":"[http://yuiblog.com/blog/?s=dojo Yahoo! User Interface Blog]"}]}, {"text":"alt ernatives to YUI", "o":[{"text":"[http://dojotoolkit.org/ Dojo - DojoToolkit.org]"}, {"text":"[http://script.aculo.us/ script.aculo.us - web 2.0 javascript]"}]}, {"text":"programming exercise", "o":[{"text":"making an outline with the treeview and JSON"}, {"text":"user", "o":[{"text":"latest photos"}, {"text":"popular tag"}]}, {"text":"e.g.,", "o":[{"text":"D:\\Document\\Interactive_University\\Docs\\2006\\01\\outline_embedding_1\\index.html"}]}]}]});
var tree
function OutlineToTree (a, parent) {
// make an outline represented by a and attach it to the parent
var label = a.text;
//var url = a[1];
var node = new YAHOO.widget.TextNode(label, parent, false);
//var node = new YAHOO.widget.HTMLNode(label, parent, false,true);
if (a.o) {
for(var i = 0; i < a.o.length; i++) {
OutlineToTree(a.o[i],node);
}
}
}
function treeInit() {
tree = new YAHOO.widget.TreeView("treeDiv1");
var root = tree.getRoot();
OutlineToTree(outline, root);
tree.draw();
//var tmpNode3 = new YAHOO.widget.HTMLNode("<a href='http://sims.berkeley.edu'>I School</a>",tmpNode,false,true);
}
</script>
</body>
</html>
How to learn YUI
-
Try out the pieces, either on the Yahoo site (e.g.,
Yahoo! UI Library: TreeView examples), on what I've set up at
Index of /~rdhyee/yui, or on your own account after downloading the code
-
Make an example work with static data first. Then think about how to get dynamic data in, probably with PHP.
-
If you are using PHP to pass data to your AJAX script, consider using
JSON. See
m. migurski / json and
PHP Hacks: Tame AJAX with JSON (Subscription only).
-
Then consider using
XMLHTTP, either directly (e.g., see
Ajax Hacks: Use Your Own Library for XMLHttpRequest or a library that presumably makes it easier, such as
Yahoo! UI Library: Connection Manager.
Good references
-
Ajax (programming) - Wikipedia, the free encyclopedia touches on most of the high-level considerations.
on Safari
-
Ajax Hacks (Rough Cuts) (subscription only)
-
Ajax Design Patterns (Rough Cuts) (subscription only)
ajax tutorials and frameworks:
