﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Colorful Day-随笔分类-AJAX</title><link>http://www.blogjava.net/blueoxygen/category/3746.html</link><description>Blue keywords,Green comment,Red breakpoint,my life is also colorful</description><language>zh-cn</language><lastBuildDate>Fri, 02 Mar 2007 03:32:05 GMT</lastBuildDate><pubDate>Fri, 02 Mar 2007 03:32:05 GMT</pubDate><ttl>60</ttl><item><title>[导入]AJAX tool box---Venkman</title><link>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35582.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Thu, 16 Mar 2006 03:19:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35582.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/35582.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35582.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/35582.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/35582.html</trackback:ping><description><![CDATA[    <img hspace="0" src="http://blueoxygen.dflying.net/3/get/ajax.jpg" align="left" border="0" /><a href="http://www.mozilla.org/projects/venkman/">Venkman </a>is a Javascript Debugger as a FireFox extenstion.It's at least powerful than IE's default script debugger(not Visual InterDev's).You can watch varaiable,set breakpoint and use &quot;step over&quot; &quot;step into&quot; &quot;step out&quot; &quot;continue&quot; buttons to debug your niffy javascript codes.<br />It's ease to use.And tutorial is HERE:http://www.svendtofte.com/code/learning_venkman/index.php<br/>
   <br>文章来源:<a href='http://blueoxygen.dflying.net/3/archive/75_ajax_tool_box---venkman.html'>http://blueoxygen.dflying.net/3/archive/75_ajax_tool_box---venkman.html</a><img src ="http://www.blogjava.net/blueoxygen/aggbug/35582.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-03-16 11:19 <a href="http://www.blogjava.net/blueoxygen/archive/2006/03/16/35582.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]variable's scope in Javascript</title><link>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35584.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Thu, 16 Mar 2006 03:19:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35584.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/35584.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35584.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/35584.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/35584.html</trackback:ping><description><![CDATA[    <p><img class="res_image" style="MARGIN: 5px" hspace="0" src="http://www.dflying.net/resserver.php?blogId=3&resource=ajax.jpg" align="left" border="0" />See DFlying's <a href="http://dflying.dflying.net/1/archive/61_javascript_variable_scope.html">finding</a>:<br />Yep,No Block Scope concept in JavaScript.Only the global and function Scope.You can use &quot;var&quot; to declare a global variable and use &quot;var&quot; agian to declare a homonymous variable in a function.In the function ,the second one works.But there is no Block scope.<br />Check the codes below,it's a demo for &quot;<strong>NO BLOCK SCOPE</strong>&quot;<br /><span class="kw2"><strong><font color="#003366">function</font></strong></span> test<span class="br0"><font color="#66cc66">(</font></span>o<span class="br0"><font color="#66cc66">)</font></span> <font color="#66cc66"><span class="br0">{</span></font><span class="kw2"><strong><font color="#003366">var</font></strong></span> i = <span class="nu0"><font color="#cc0000">0</font></span>; <font color="#009900"><span class="co1">// i is defined throughout function</span></font><span class="kw1"><strong><font color="#000066">if</font></strong></span> <span class="br0"><font color="#66cc66">(</font></span><span class="kw1"><strong><font color="#000066">typeof</font></strong></span> o == <span class="st0"><font color="#3366cc">&quot;object&quot;</font></span><span class="br0"><font color="#66cc66">)</font></span> <font color="#66cc66"><span class="br0">{</span></font><span class="kw2"><strong><font color="#003366">var</font></strong></span> j = <span class="nu0"><font color="#cc0000">0</font></span>; <font color="#009900"><span class="co1">// j is defined everywhere, not just block</span></font><span class="kw1"><strong><font color="#000066">for</font></strong></span><span class="br0"><font color="#66cc66">(</font></span><span class="kw2"><strong><font color="#003366">var</font></strong></span> k = <span class="nu0"><font color="#cc0000">0</font></span>; k &lt; <span class="nu0"><font color="#cc0000">10</font></span>; k++<span class="br0"><font color="#66cc66">)</font></span> <span class="br0"><font color="#66cc66">{</font></span> <font color="#009900"><span class="co1">// k is defined everywhere, not just loop</span></font>document.<span class="kw1"><strong><font color="#000066">write</font></strong></span><span class="br0"><font color="#66cc66">(</font></span>k<span class="br0"><font color="#66cc66">)</font></span>;<br /><br /><font color="#66cc66"><span class="br0">}</span></font>document.<span class="kw1"><strong><font color="#000066">write</font></strong></span><span class="br0"><font color="#66cc66">(</font></span>k<span class="br0"><font color="#66cc66">)</font></span>; <font color="#009900"><span class="co1">// k is still defined: prints 10</span></font><font color="#66cc66"><span class="br0">}</span></font>document.<span class="kw1"><strong><font color="#000066">write</font></strong></span><span class="br0"><font color="#66cc66">(</font></span>j<span class="br0"><font color="#66cc66">)</font></span>; <font color="#009900"><span class="co1">// j is defined, but may not be initialized</span></font><span class="br0"><font color="#66cc66">}</font></span> </p><p><strong>But,You still need to care javascript's FUNCTION SCOPE.</strong>Also see code snippet:<br /><span class="kw2"><strong><font color="#003366">var</font></strong></span> scope = <span class="st0"><font color="#3366cc">&quot;global&quot;</font></span>;<br /><br /><span class="kw2"><strong><font color="#003366">function</font></strong></span> f<span class="br0"><font color="#66cc66">(</font></span> <span class="br0"><font color="#66cc66">)</font></span> <font color="#66cc66"><span class="br0">{</span></font><span class="kw3"><font color="#000066">alert</font></span><span class="br0"><font color="#66cc66">(</font></span>scope<span class="br0"><font color="#66cc66">)</font></span>; <font color="#009900"><span class="co1">// Displays &quot;undefined&quot;, not &quot;global&quot;</span></font><span class="kw2"><strong><font color="#003366">var</font></strong></span> scope = <span class="st0"><font color="#3366cc">&quot;local&quot;</font></span>; <font color="#009900"><span class="co1">// Variable initialized here, but defined everywhere</span></font><span class="kw3"><font color="#000066">alert</font></span><span class="br0"><font color="#66cc66">(</font></span>scope<span class="br0"><font color="#66cc66">)</font></span>; <font color="#009900"><span class="co1">// Displays &quot;local&quot;</span></font><font color="#66cc66"><span class="br0">}</span></font>f<span class="br0"><font color="#66cc66">(</font></span> <span class="br0"><font color="#66cc66">)</font></span>; <br />Right,thought you alert(scope) first and then define a new functin scope variable scope.However,once you define a function scope vriable,it will hide the global variable in the function body,whatever the definition order.</p><br/>
   <br>文章来源:<a href='http://blueoxygen.dflying.net/3/archive/68_variables_scope_in_javascript.html'>http://blueoxygen.dflying.net/3/archive/68_variables_scope_in_javascript.html</a><img src ="http://www.blogjava.net/blueoxygen/aggbug/35584.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-03-16 11:19 <a href="http://www.blogjava.net/blueoxygen/archive/2006/03/16/35584.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]AJAX Auto-complete component</title><link>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35585.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Thu, 16 Mar 2006 03:19:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35585.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/35585.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35585.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/35585.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/35585.html</trackback:ping><description><![CDATA[    <img hspace="0" src="http://blueoxygen.dflying.net/3/get/ajax.jpg" align="left" border="0" />&#26412;&#26469;&#36824;&#35201;&#33258;&#24049;&#20889;&#19968;&#20010;auto-complete&#65292;&#20294;&#26159;&#22823;&#22810;&#25968;&#27492;&#31867;&#21151;&#33021;&#24182;&#27809;&#26377;&#25552;&#20379;&#31867;&#20284;google suggest&#25552;&#20379;&#30340;&#38190;&#30424;&#36873;&#25321;&#21151;&#33021;&#65292;auto-complete&#20415;&#22833;&#21435;&#20102;&#19968;&#22823;&#21322;&#30340;&#20132;&#20114;&#25913;&#21892;&#12290;&#20110;&#26159;&#21069;&#20004;&#22825;&#36824;&#29305;&#24847;&#25170;&#20102;google suggest&#26469;&#30475;ac.js &#21457;&#29616;google&#23450;&#26159;&#29992;&#20102;&#28151;&#28102;&#22120;&#12290;&#34429;&#28982;&#20195;&#30721;&#27809;&#26377;&#21387;&#32553;&#65292;&#20294;&#26159;&#20195;&#30721;&#30340;&#22238;&#36710;&#31354;&#34892;&#21644;&#20989;&#25968;&#21517;&#23383;&#20840;&#37096;&#28151;&#20081;&#12290;&#27491;&#22312;&#35201;&#33258;&#24049;&#20889;&#30340;&#26102;&#20505;&#21457;&#29616;&#20102;&#27492;&#20013;&#22269;&#33258;&#20135;&#30340;AutoAssist&#12290;Very Cool!<br /><br /><div id="Clipmarks6BorderDiv8618" style="BORDER-RIGHT: orange 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: orange 2px solid; DISPLAY: none; PADDING-LEFT: 0px; Z-INDEX: 99999; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: orange 2px solid; WIDTH: 0px; PADDING-TOP: 0px; BORDER-BOTTOM: orange 2px solid; POSITION: absolute"></div><div id="Clipmarks277BorderDiv4702" style="BORDER-RIGHT: orange 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: orange 2px solid; DISPLAY: none; PADDING-LEFT: 0px; Z-INDEX: 99999; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: orange 2px solid; WIDTH: 0px; PADDING-TOP: 0px; BORDER-BOTTOM: orange 2px solid; POSITION: absolute"></div><div id="Clipmarks246BorderDiv6480" style="BORDER-RIGHT: orange 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: orange 2px solid; DISPLAY: none; PADDING-LEFT: 0px; Z-INDEX: 99999; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: orange 2px solid; PADDING-TOP: 0px; BORDER-BOTTOM: orange 2px solid; POSITION: absolute; HEIGHT: 0px"></div><div id="Clipmarks27BorderDiv7329" style="BORDER-RIGHT: orange 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: orange 2px solid; DISPLAY: none; PADDING-LEFT: 0px; Z-INDEX: 99999; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: orange 2px solid; PADDING-TOP: 0px; BORDER-BOTTOM: orange 2px solid; POSITION: absolute; HEIGHT: 0px"></div><br/><div class="entry-body"><p><a href="http://capxous.com/autoassist/">AutoAssist</a> is an auto completion web widget that written in pure JavaScript. It can help enhance the accessibility of existing website, let the users to work effective and feel comfortable. AutoAssist Javascript only and is built upon prototype and rico. Its main features are :</p><p>* improve the User Experience<br />* Don't require an Ajax experience<br />* pretty managed JavaScript, easy to understand and customize<br />* works well on Mozilla/FireFox, IE and Opera<br />* have a nice solution for fast user typing, reduce a lot of corresponding server loading (20% - 80% *)</p><center><img height="128" alt="autoassist.png" src="http://ajax.phpmagazine.net/upload/2006/03/autoassist.png" width="383" /></center></div><div style="MARGIN-TOP: 0px; FLOAT: left; MARGIN-RIGHT: 3px"><!-- ads --></div><p>The code for the screenshot is very simple : </p><pre class="code">var foo = function() {<br />    var tt = new AutoAssist(&quot;t&quot;, {setRequestOptions: function() {<br />            var pars = &quot;name=&quot; + this.txtBox.value;<br />            return { url: &quot;/country.php&quot;, parameters: pars };<br />        }});<br />}<br />Event.observe(window, &quot;load&quot;, foo);</pre><p>You can find a <a href="http://capxous.com/autoassist/ten-minutes-tutorial/">ten minutes tutorial for AutoAssist</a> explaining in details how to use this script to create an auto-complete list based on country data.</p><p>By the way,script.aculo.us also has it's impelmention:http://demo.script.aculo.us/ajax/autocompleter</p><div id="Clipmarks6BorderDiv8618" style="BORDER-RIGHT: orange 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: orange 2px solid; DISPLAY: none; PADDING-LEFT: 0px; Z-INDEX: 99999; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: orange 2px solid; WIDTH: 0px; PADDING-TOP: 0px; BORDER-BOTTOM: orange 2px solid; POSITION: absolute"></div><div id="Clipmarks277BorderDiv4702" style="BORDER-RIGHT: orange 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: orange 2px solid; DISPLAY: none; PADDING-LEFT: 0px; Z-INDEX: 99999; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: orange 2px solid; WIDTH: 0px; PADDING-TOP: 0px; BORDER-BOTTOM: orange 2px solid; POSITION: absolute"></div><div id="Clipmarks246BorderDiv6480" style="BORDER-RIGHT: orange 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: orange 2px solid; DISPLAY: none; PADDING-LEFT: 0px; Z-INDEX: 99999; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: orange 2px solid; PADDING-TOP: 0px; BORDER-BOTTOM: orange 2px solid; POSITION: absolute; HEIGHT: 0px"></div><div id="Clipmarks27BorderDiv7329" style="BORDER-RIGHT: orange 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: orange 2px solid; DISPLAY: none; PADDING-LEFT: 0px; Z-INDEX: 99999; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: orange 2px solid; PADDING-TOP: 0px; BORDER-BOTTOM: orange 2px solid; POSITION: absolute; HEIGHT: 0px"></div>
   <br>文章来源:<a href='http://blueoxygen.dflying.net/3/archive/53_ajax_auto-complete_component.html'>http://blueoxygen.dflying.net/3/archive/53_ajax_auto-complete_component.html</a><img src ="http://www.blogjava.net/blueoxygen/aggbug/35585.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-03-16 11:19 <a href="http://www.blogjava.net/blueoxygen/archive/2006/03/16/35585.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Prototype Samples</title><link>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35578.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Thu, 16 Mar 2006 03:18:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35578.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/35578.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/03/16/35578.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/35578.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/35578.html</trackback:ping><description><![CDATA[写了一些sample在我的Blog上面。还没入门的朋友可以看看<BR><A href="http://blueoxygen.dflying.net/3/archive/20_prototype_samples.html">http://blueoxygen.dflying.net/3/archive/20_prototype_samples.html</A><img src ="http://www.blogjava.net/blueoxygen/aggbug/35578.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-03-16 11:18 <a href="http://www.blogjava.net/blueoxygen/archive/2006/03/16/35578.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX贴贴脸之示例1-1</title><link>http://www.blogjava.net/blueoxygen/archive/2006/02/23/32101.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Thu, 23 Feb 2006 06:52:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/02/23/32101.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/32101.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/02/23/32101.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/32101.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/32101.html</trackback:ping><description><![CDATA[为AJAX贴贴脸系列文章。第一篇为<A title="AJAX贴贴脸 入门篇" HREF="/blueoxygen/archive/2005/11/24/21197.html" target="">AJAX贴贴脸之入门篇</A>。本示例部分操作利用了prototype类库，<A HREF="/blueoxygen/admin/compdoc2cn.dev.java.net/prototype/html/prototype.js.cn.html">相关知识请查阅</A><BR>示例为我们以前经常遇到过的动态列表问题，当选择一个下拉框的时候，另外一个的数据将动态产生。<BR><IMG height=207 alt=result.jpg src="http://www.blogjava.net/images/blogjava_net/blueoxygen/result.jpg" width=417 border=0><BR>这是个极其简单的应用。不过我们讲由简入繁，最后的示例会展现Google Suggest类型的自动提示。而且我们会不停的对整个示例重构，标题的1-1也表明有1-2等。<BR>1-1是完全自己处理AJAX的各种问题，1-2预计引入其他类库来操作XML，1-3预计用buffalo完成此示例。之后每个示例如果有必要都会有此类对比。由于代码很简单并且有注释，所以文章以代码即可展现应用。<BR><BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #0000ff">&lt;!</SPAN><SPAN style="COLOR: #ff00ff">DOCTYPE&nbsp;HTML&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;HTML&nbsp;4.0&nbsp;Transitional//EN"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">html</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">head</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;Dynamic&nbsp;List&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">meta&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Generator"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;content</SPAN><SPAN style="COLOR: #0000ff">="EditPlus"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">meta&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Author"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;content</SPAN><SPAN style="COLOR: #0000ff">=""</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">meta&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Keywords"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;content</SPAN><SPAN style="COLOR: #0000ff">=""</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">meta&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="Description"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;content</SPAN><SPAN style="COLOR: #0000ff">=""</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">src</SPAN><SPAN style="COLOR: #0000ff">="./script/prototype.js"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;xmlHttp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">XHR&nbsp;Object</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;refreshBookList()&nbsp;{<BR></SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;bookCate&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;$F('bookCate');<BR>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">clear&nbsp;Books&nbsp;select&nbsp;box</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(bookCate&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">==</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">""</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<BR>&nbsp;&nbsp;&nbsp;&nbsp;clearBookList();<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">return</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">we&nbsp;use&nbsp;XML&nbsp;file&nbsp;directly&nbsp;for&nbsp;demonstrating.</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">In&nbsp;real&nbsp;application,you&nbsp;should&nbsp;generate&nbsp;*.xml&nbsp;file&nbsp;by&nbsp;server&nbsp;side</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;url;<BR>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(bookCate&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">==</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">SAP</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<BR>&nbsp;&nbsp;&nbsp;&nbsp;url&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">./SAP.xml</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;}</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">else</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;url&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">./SIEBEL.xml</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;pars&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">""</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">Create&nbsp;a&nbsp;new&nbsp;XHR&nbsp;object</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;xmlHttp&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;Ajax.Request(url,{method:&nbsp;'get',onComplete:&nbsp;handleListChange});<BR>}<BR></SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">remove&nbsp;list&nbsp;values&nbsp;of&nbsp;select&nbsp;box</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;clearBookList()&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;books&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;$('bookList');<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">while</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(books.childNodes.length&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&gt;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;books.removeChild(books.childNodes[</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR></SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">callback&nbsp;function</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">function</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;handleListChange(originalRequest){<BR>&nbsp;&nbsp;&nbsp;&nbsp;clearBookList();<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;books&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;$('bookList');<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;results&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;originalRequest.responseXML;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;option&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">null</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;booksXML&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;results.getElementsByTagName(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">books</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)[</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">];<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">for</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&lt;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;booksXML.childNodes.length;i</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">++</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">//</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5">get&nbsp;book&nbsp;tag</SPAN><SPAN style="COLOR: #008000; BACKGROUND-COLOR: #f5f5f5"><BR></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">var</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;listItem&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;booksXML.childNodes[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;document.createElement('option');<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;option.appendChild(document.createTextNode(listItem.firstChild.nodeValue));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;books.appendChild(option);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">head</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">body</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">form&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #ff0000">action</SPAN><SPAN style="COLOR: #0000ff">="#"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;Book&nbsp;Categroies:<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">select&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="bookCate"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="bookCate"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;onchange</SPAN><SPAN style="COLOR: #0000ff">="refreshBookList();"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">option</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">Select&nbsp;One</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">option</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">option&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="SAP"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">SAP&nbsp;Books</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">option</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">option&nbsp;</SPAN><SPAN style="COLOR: #ff0000">value</SPAN><SPAN style="COLOR: #0000ff">="SIEBLE"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">SIEBEL&nbsp;Books</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">option</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">select</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">br</SPAN><SPAN style="COLOR: #0000ff">/&gt;&lt;</SPAN><SPAN style="COLOR: #800000">br</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">select&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="bookList"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;id</SPAN><SPAN style="COLOR: #0000ff">="bookList"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;size</SPAN><SPAN style="COLOR: #0000ff">="6"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;style</SPAN><SPAN style="COLOR: #0000ff">="width:300px"</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;/</SPAN><SPAN style="COLOR: #800000">select</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">br</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">form</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">body</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">html</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN></DIV>SAP.xml<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #0000ff">&lt;?</SPAN><SPAN style="COLOR: #ff00ff">xml&nbsp;version="1.0"&nbsp;encoding="ISO-8859-1"</SPAN><SPAN style="COLOR: #0000ff">?&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">books</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>ABAP<BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>BW<BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>FI&nbsp;module<BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">books</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV>SIEBEL.xml<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #0000ff">&lt;?</SPAN><SPAN style="COLOR: #ff00ff">xml&nbsp;version="1.0"&nbsp;encoding="ISO-8859-1"</SPAN><SPAN style="COLOR: #0000ff">?&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">books</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>SIEBEL<BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR>CRM<BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">book</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">books</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV><img src ="http://www.blogjava.net/blueoxygen/aggbug/32101.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-02-23 14:52 <a href="http://www.blogjava.net/blueoxygen/archive/2006/02/23/32101.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX Data Transfer Types</title><link>http://www.blogjava.net/blueoxygen/archive/2006/02/23/32079.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Thu, 23 Feb 2006 03:15:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/02/23/32079.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/32079.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/02/23/32079.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/32079.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/32079.html</trackback:ping><description><![CDATA[<P>AJAX与服务器端通讯，虽然XHR对象的介入使得我们可以异步处理用户请求，但是另外一个细节也暴露给我，我们如何与服务器统一通信的契约？<BR></P>
<P>目前比较公认的有三种数据传输交互方式：XHTML Fragment,JSON,XML。当然也有不同的声音，这里也会介绍。</P>
<DIV align=left>
<UL>
<LI><B>XHTML片断</B></LI></UL></DIV>
<DIV align=left>这种方式也被称为<A title="Asychronous HTML and HTTP" href="http://www.ajaxcn.org/exec/version?name=Ajax/AHAH&amp;version=2">AHAH</A>, 目前很多遗留系统想沾AJAX的光改善一下交互，节省一下带宽，大多数采用了此种方式。我们以 Struts为例子，比如在页面上有一个按钮，点击后得到现在我收藏的图书列表，则此图书列表(Table元素组成)便可以以XHTML片断的形式返回客户端，然后利用XHR对象的responseText属性得到，设知道某DIV中。<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_67_430_Open_Image onclick="this.style.display='none'; Codehighlighter1_67_430_Open_Text.style.display='none'; Codehighlighter1_67_430_Closed_Image.style.display='inline'; Codehighlighter1_67_430_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_67_430_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_67_430_Closed_Text.style.display='none'; Codehighlighter1_67_430_Open_Image.style.display='inline'; Codehighlighter1_67_430_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">&nbsp;(Iterator&nbsp;it&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;sortedPresidentsList.iterator();&nbsp;it.hasNext();)&nbsp;</SPAN><SPAN id=Codehighlighter1_67_430_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_67_430_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>HashMap&nbsp;hm&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;(HashMap)it.next();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;tr&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;(String)hm.get(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">firstName</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;(String)hm.get(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">middleName</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;(String)hm.get(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">lastName</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;(String)hm.get(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">firstYearInOffice</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;(String)hm.get(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">lastYearInOffice</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/td&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/tr&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>html&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&lt;/table&gt;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Write&nbsp;the&nbsp;HTML&nbsp;to&nbsp;response</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">response.setContentType(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">text/html</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>PrintWriter&nbsp;out&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;response.getWriter();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>out.println(html);<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>out.flush();</SPAN></DIV><BR></DIV>
<UL></UL>
<P></P>
<DIV style="BACKGROUND: rgb(204,204,255) 0% 50%; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial">
<P></P></DIV>
<P>这是一个Struts的例子，Action中response直接flush输出。当然也可以让Struts导向到结果jsp页面，请求的XHR可以得到jsp生成的HTML内容。<BR>缺点是：当返回有Form的内容的时候会崩溃。CSS样式设置复杂。</P>
<UL>
<LI><B>XML</B></LI></UL>
<P>XML在很多AJAX示例当中作为数据传递的标准。而XML具有很好的数据语义描述性，服务器端生成方式众多，而几乎所有浏览器都支持对XML 的解析。以JavaScript解析服务器端返回的XML为例子，只需要XHR的responseXML属性即可获得XML由javascript解析 (请看我在BlogJAVA写的<A title=Javascript操作xml小小showcase:xml转换为table HREF="/blueoxygen/archive/2006/02/15/30882.html">操作示例</A>) 而XML的产生方式似乎所有人都认准了<BR></P>
<P></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">channel</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">Dan's&nbsp;Data</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">description</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">New&nbsp;and&nbsp;interesting&nbsp;computer&nbsp;hardware,&nbsp;gadgets&nbsp;and&nbsp;toys&nbsp;reviewed.&nbsp;And&nbsp;letters.&nbsp;Lots&nbsp;of&nbsp;letters.</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">description</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">link</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">http://www.dansdata.com/</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">link</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">item</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">Ultrasone&nbsp;HFI-650&nbsp;headphones</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">title</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">description</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">They&nbsp;look&nbsp;like&nbsp;the&nbsp;550s,&nbsp;they&nbsp;feel&nbsp;like&nbsp;the&nbsp;550s,&nbsp;they've&nbsp;got&nbsp;marketing&nbsp;buzzwords&nbsp;like&nbsp;the&nbsp;550s&nbsp;-&nbsp;are&nbsp;they&nbsp;worth&nbsp;the&nbsp;extra&nbsp;money?</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">description</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">link</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">http://www.dansdata.com/quickshot025.htm</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">link</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">item</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/dot.gif"><IMG src="http://www.blogjava.net/images/dot.gif"><IMG src="http://www.blogjava.net/images/dot.gif"><IMG src="http://www.blogjava.net/images/dot.gif"><IMG src="http://www.blogjava.net/images/dot.gif">..<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P><BR>一类，似乎这样子语义描述更清楚。但是我从michael那里得到启示，确实，用此类方式传输数据几乎无法在客户端统一处理。从我的showcase中大家也可以看到，Javascript解析XML后更新DOM简直就是体力活，枯燥且容易出错，而此种XML返回的数据则会千差万别，以寻找特定tag的节点的方式怎么能统一处理呢？于是，第二种XML传输方式应运而生。</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">list</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">type</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">java.util.List</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">type</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">map</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">type</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">yourapp.domain.Book</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">type</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">title</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">JavaScript,&nbsp;the&nbsp;Definitive&nbsp;Guide</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">publisher</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">O'Reilly</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">author</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">David&nbsp;Flanagan</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">cover</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">/images/cover_defguide.jpg</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">blurb</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">Lorem&nbsp;ipsum&nbsp;dolor&nbsp;sit&nbsp;amet,&nbsp;consectetuer&nbsp;adipiscing&nbsp;elit.</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">map</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">map</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">type</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">yourapp.domain.Book</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">type</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">title</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">DOM&nbsp;Scripting</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">publisher</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">Friends&nbsp;of&nbsp;Ed</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">author</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">Jeremy&nbsp;Keith</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">cover</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">/images/cover_domscripting.jpg</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">blurb</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">Praesent&nbsp;et&nbsp;diam&nbsp;a&nbsp;ligula&nbsp;facilisis&nbsp;venenatis.</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">string</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">map</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">list</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV>
<P>这样子只要客户端和服务器端达成共识string long int等代表的数据类型就可以在两端还原成自己可用的对象。而这也是micheal认为真正的AJAX应该有的形态，其中AJAX引擎便承担起了这份工作。<BR>缺点：XML的构造和解析在没有类库辅助的情形下是一个灾难，而XML文件的传输效率似乎也不如简单的文本高。我讲会在后面的blog中提及XML文件的产生方法，以及客户端一些解析的框架。</P>
<UL>
<LI>JSON</LI></UL>
<P><A href="http://www.crockford.com/JSON/index.html">JSON</A>是JavaScript Object Notation的缩写，是一份规范，定义了极其简单的数据描述形式。几乎在所有主流语言上都有实现。JSON对象是名/值对的集合，所以一个简单的JSON对象为：<BR>var testObj={<BR>"name" : david,<BR>"sex" : Male,<BR>"work" : SE<BR>}<BR>客户端javascript调用eval()就可以解析由服务器端产生的JSON串。var jsonExpression =<BR>( + req.responseText + );<BR>var customer = eval(jsonExpression);<BR>而服务器端(JAVA)也有相应的lib来操作：JSONObject 的toString() <BR>缺点：虽然JSON简洁高效，但是转化为Javascript对象通过eval()也就是说，AJAX的传输邦定在了JSON上面，这样，总会让人不很放心。并且JSON对象难于阅读与理解，不如XML直观。</P>
<P>除了会在下一篇AJAX的blog介绍JAVA对象序列化到XML以外，会一些从头开始构建应用的例子，其中不会使用buffalo DWR一类的框架，我会尝试选用不同的方案作为数据传输方式供大家参考。</P><img src ="http://www.blogjava.net/blueoxygen/aggbug/32079.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-02-23 11:15 <a href="http://www.blogjava.net/blueoxygen/archive/2006/02/23/32079.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Javascript操作xml小小showcase:xml转换为table</title><link>http://www.blogjava.net/blueoxygen/archive/2006/02/15/30882.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Wed, 15 Feb 2006 14:58:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/02/15/30882.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/30882.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/02/15/30882.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/30882.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/30882.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &lt;!DOCTYPE&nbsp;HTML&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;HTML&nbsp;4.0&nbsp;Transitional//EN"&gt;&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;&nbsp;New&nbsp;Document&nbsp;&lt;/TITLE&gt;&lt;META&nbsp;NAME="Ge...&nbsp;&nbsp;<a href='http://www.blogjava.net/blueoxygen/archive/2006/02/15/30882.html'>阅读全文</a><img src ="http://www.blogjava.net/blueoxygen/aggbug/30882.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-02-15 22:58 <a href="http://www.blogjava.net/blueoxygen/archive/2006/02/15/30882.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Behaviour.js 真正的清洁了html？</title><link>http://www.blogjava.net/blueoxygen/archive/2005/11/24/21354.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Thu, 24 Nov 2005 15:10:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2005/11/24/21354.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/21354.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2005/11/24/21354.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/21354.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/21354.html</trackback:ping><description><![CDATA[<P align=justify><A href="http://bennolan.com/behaviour/"><FONT face=Arial>http://bennolan.com/behaviour/</FONT></A><FONT face=Arial>&nbsp;&nbsp; 为了避免在html中引入过多的script tag，尤其现在富客户端应用很火的时候，script写的就越发的多。<BR>官方网站举了一个这样子的例子<BR></P></FONT>
<DIV align=justify>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
<P><FONT size=3><FONT face=Arial><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">div&nbsp;</SPAN><SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000ff">="image_16209134_normal"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></FONT></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial size=3><IMG id=Codehighlighter1_63_152_Open_Image onclick="this.style.display='none'; Codehighlighter1_63_152_Open_Text.style.display='none'; Codehighlighter1_63_152_Closed_Image.style.display='inline'; Codehighlighter1_63_152_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_63_152_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_63_152_Closed_Text.style.display='none'; Codehighlighter1_63_152_Open_Image.style.display='inline'; Codehighlighter1_63_152_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></FONT></SPAN><FONT size=3><FONT face=Arial><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">language</SPAN><SPAN style="COLOR: #0000ff">="Javascript"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN id=Codehighlighter1_63_152_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN></FONT></FONT><SPAN id=Codehighlighter1_63_152_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><BR><FONT face=Arial size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>photo_hash['</FONT></SPAN><FONT size=3><FONT face=Arial><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">16209134</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">']&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">new</SPAN></FONT></FONT><FONT size=3><FONT face=Arial><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">&nbsp;Object();<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>photo_hash['</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">16209134</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">'].title&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</SPAN></FONT></FONT><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><FONT face=Arial size=3>&nbsp;'2am&nbsp;on&nbsp;Saturday';<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN></SPAN><FONT size=3><FONT face=Arial><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></FONT></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT size=3><FONT face=Arial><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">h4&nbsp;</SPAN><SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000ff">="title_div16209134"</SPAN></FONT></FONT><FONT size=3><FONT face=Arial><SPAN style="COLOR: #ff0000">&nbsp;<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;style</SPAN><SPAN style="COLOR: #0000ff">="margin-bottom:&nbsp;0px;&nbsp;margin-top:&nbsp;0px;"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></FONT></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;2am&nbsp;on&nbsp;Saturday<BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT size=3><FONT face=Arial><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">h4</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></FONT></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial size=3><IMG id=Codehighlighter1_292_331_Open_Image onclick="this.style.display='none'; Codehighlighter1_292_331_Open_Text.style.display='none'; Codehighlighter1_292_331_Closed_Image.style.display='inline'; Codehighlighter1_292_331_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_292_331_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_292_331_Closed_Text.style.display='none'; Codehighlighter1_292_331_Open_Image.style.display='inline'; Codehighlighter1_292_331_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></FONT></SPAN><FONT size=3><FONT face=Arial><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">script&nbsp;</SPAN><SPAN style="COLOR: #ff0000">type</SPAN><SPAN style="COLOR: #0000ff">="text/javascript"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN id=Codehighlighter1_292_331_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_292_331_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">initPhotosUserPageTitle_div('</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">16209134</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">');</SPAN></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">script</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></FONT></FONT><SPAN style="COLOR: #000000"><BR><FONT face=Arial size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN></P></DIV></DIV>
<P align=justify><FONT face=Arial>这是Flickr上面一段代码。确实，它使得代码阅读起来结构不清晰了。Behavior应用之后，不需在元素上写明触发事件要执行的方法，比如<BR>&lt;a onclick="this.parentNode.removeChild(this)" href="#"&gt;<BR>Click me to delete me<BR>&lt;/a&gt;<BR>而变成了<BR>&lt;ul id="example"&gt;<BR>&lt;li&gt;<BR>&lt;a href="/someurl"&gt;Click me to delete me&lt;/a&gt;<BR>&lt;/li&gt;<BR>&lt;/ul&gt;<BR>那么javascript如果找到这个a链接并加上onclick事件方法的呢？采用css selector<BR></P></FONT>
<P align=justify><FONT face=Arial>var myrules = {
&nbsp;<BR>'<SPAN class=selector>#example li</SPAN>' : function(el){
&nbsp;	<BR>el.<SPAN class=event>onclick</SPAN> = function(){
&nbsp;&nbsp;	<BR><SPAN class=beh>this.parentNode.removeChild(this);</SPAN>
&nbsp;	<BR>}	}};<BR><STRONG>Behaviour.register(myrules);</STRONG>
确实看起来，html清爽了，但是，却引入了其他的元素。ok，我们可以为每个控件定义id，其实也未尝不可，asp.net不也是web component开发的时候都定义id的么？可似乎又脱裤子放屁之嫌。在维护一个对某一组应用相同样式或响应<BR>相同方法的html控件上应用behavior，有意义，起码不必每个上面都写上onclick之类的，但是对于更普遍的应用，每个html控件要做得事情是不同的啊。那个时候，不但用behavior代码量增加了，而且维护一个var myrules里的内容和去删除控件上的onclick其实工作量差不多。真正的应用可不是demo啊，列出来一排link写着remove me，然后执行一样的动作。 <BR>不过正如我上面说的，还是有一定的应用场景的，大家可以在有此需求的时候考虑，还有一Behaviour.js<BR><BR><BR><BR><BR><BR></FONT></P><img src ="http://www.blogjava.net/blueoxygen/aggbug/21354.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2005-11-24 23:10 <a href="http://www.blogjava.net/blueoxygen/archive/2005/11/24/21354.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX贴贴脸 入门篇 </title><link>http://www.blogjava.net/blueoxygen/archive/2005/11/24/21197.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Wed, 23 Nov 2005 16:21:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2005/11/24/21197.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/21197.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2005/11/24/21197.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/21197.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/21197.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 本想翻译IBM的一篇文章 Build apps using Asynchronous JavaScript with XML 但是发现不如就按照那个方式想怎么写就怎么写。之后有时间了会把其中的一个系列从基本应用到使用DWR框架的翻出来，也许对一些被AJAX buzz word一直骚扰但是没亲密接触的人有些用处。嗯，把dojo也列入计划吧，但愿我能坚持。由于JAVA版 servlet+web.xml...&nbsp;&nbsp;<a href='http://www.blogjava.net/blueoxygen/archive/2005/11/24/21197.html'>阅读全文</a><img src ="http://www.blogjava.net/blueoxygen/aggbug/21197.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2005-11-24 00:21 <a href="http://www.blogjava.net/blueoxygen/archive/2005/11/24/21197.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>