﻿<?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-JRobot-文章分类-xml相关</title><link>http://www.blogjava.net/JRobot/category/2763.html</link><description>java相关技术,eclipse,swt,jface</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 08:40:02 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 08:40:02 GMT</pubDate><ttl>60</ttl><item><title>XAJAX 编程入门实例两则</title><link>http://www.blogjava.net/JRobot/articles/69490.html</link><dc:creator>JRobot</dc:creator><author>JRobot</author><pubDate>Wed, 13 Sep 2006 14:25:00 GMT</pubDate><guid>http://www.blogjava.net/JRobot/articles/69490.html</guid><wfw:comment>http://www.blogjava.net/JRobot/comments/69490.html</wfw:comment><comments>http://www.blogjava.net/JRobot/articles/69490.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JRobot/comments/commentRss/69490.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JRobot/services/trackbacks/69490.html</trackback:ping><description><![CDATA[
		<h1 class="ContentTitle">
				<strong>
				</strong>作者:snow 日期:2006-01-25</h1>
						     
						   
						    
						  
					             XAJAX是一个比较优秀的AJAX toolkit工具，安装很简单，就是吧他的xajax.inc.php文件copy到你制定的目录下面就可以了。<br />下面举两个列子来说明如何使用<br /><br />1）helloworld<br />helloworld是每一个编程语言所必须的，所以这里也不例外，我会就代码给出解释<br /><br /><br /><span class="Code"><br /><font color="#000000">&lt;?php<br />// helloworld.php demonstrates a very basic xajax implementation<br />// using xajax version 0.1 beta4<br />// </font><a href="http://xajax.sourceforge.net/" target="_blank">http://xajax.sourceforge.n...</a><br /><br /><font color="#000000">require ('xajax.inc.php');  #必须的，放到脚本的最前面<br /><br />#调用函数，该函数被javascript调用<br />function helloWorld($isCaps)<br />{ <br />if ($isCaps)<br />$text = "HELLO WORLD!";<br />else<br />$text = "Hello World!";<br /><br />$objResponse = new xajaxResponse();<br />$objResponse-&gt;addAssign("div1","innerHTML",$text); #给id为div1的html元素的innerHTML属性分配$text指，其他的方法请参考前面贴出的XAJAX介绍<br /><br />return $objResponse-&gt;getXML();   #返回赋值后的代码，采用xml格式<br />}<br /><br />// Instantiate the xajax object. No parameters defaults requestURI to this page, method to POST, and debug to off<br />$xajax = new xajax();<br /><br />//$xajax-&gt;debugOn(); // Uncomment this line to turn debugging on<br /><br />// Specify the PHP functions to wrap. The JavaScript wrappers will be named xajax_functionname<br />$xajax-&gt;registerFunction("helloWorld"); #注册函数，这个也是必须的，用来保证，javascript能调用php里面的函数<br />// Process any requests. Because our requestURI is the same as our html page,<br />// this must be called before any headers or HTML output have been sent<br />$xajax-&gt;processRequests();<br />?&gt;<br />&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "</font><a href="http://www.w3.org/TR/xhtm......-transitional.dtd&amp;quot;&amp;gt;" target="_blank">http://www.w3.org/TR/xhtm....</a><br /><font color="#000000">&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;xajax example&lt;/title&gt;<br />&lt;?php <br />#输出javascript脚本，这个方法必须放在head之间，特别是应该放在&lt;html&gt;标签之前，否则无法工组<br />$xajax-&gt;printJavascript(); <br />?&gt;<br />&lt;/head&gt;<br />&lt;body style="text-align:center;"&gt;<br />&lt;div id="div1" name="div1"&gt;&amp;#160;&lt;/div&gt;<br />&lt;br/&gt;<br /><br />&lt;button onclick="xajax_helloWorld(0)" &gt;Click Me&lt;/button&gt;<br />&lt;button onclick="xajax_helloWorld(1)" &gt;CLICK ME&lt;/button&gt;<br />&lt;script type="text/javascript"&gt;<br />xajax_helloWorld(0); // call the helloWorld function to populate the div on load<br />&lt;/script&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</font></span><br /><br />上面的脚本是一个简单的例子，但是体现了XAJAX使用的一个流程。需要注意的是在html脚本中，我们调用的函数名是<br />xajax_helloWorld
(),但是我们编程和注册的函数名却是helloWorld，这不是一个错误，而是必须这样做，你可以查看xajax.inc.php的代码就知道，他默
认的在html调用的函数名前缀就是xajax_helloWorld()，因此如果你不修改xajax.inc.php，那么你在html里面调用函数
就必须加上xajax_这样的前缀。<br /><br /><a href="http://mlsx.xplore.cn/up/File/helloworld.php">程序演示</a><br /><br />2）表单处理<br />这个例子是我花时间比较多的，也是大家比较关心的，虽然官方也给出了一个form的例子，但是对表单数据的处理都是自己再重新写的函数，而没有使用xajax.getFormValues函数，个人觉得比较复杂。下面是官方的form演示和源代码<br /><br /><a href="http://xajax.sourceforge.net/signup.php">form演示</a><br /><br /><a href="http://xajax.sourceforge.net/signup.php.txt">form源代码</a><br /><br />下面是我的代码<br /><br /><font color="#000000"><span class="Code">&lt;?php<br />require("includes/xajax.inc.php");<br />function doSomething( $formData )<br />{ <br />$objResponse = new xajaxResponse();<br />$str="";<br />foreach($formData as $key=&gt;$value)<br />if (empty($str))<br />$str.=$key."='".$value."'";<br />else<br />$str.=",".$key."='".$value."'";<br />//$str="form data is ".implode(",",$formData);<br />//$objResponse-&gt;addAlert(print_r($formData));<br />$objResponse-&gt;addAssign("result", "innerHTML", $str );<br />return $objResponse-&gt;getXML();<br />}<br /><br />function hb()<br />{ <br />$objResponse = new xajaxResponse();<br />$objResponse-&gt;addAssign("doIt", "value", "Working...");<br />$objResponse-&gt;addAssign("doIt", "disabled", true);<br />$objResponse-&gt;addScript("xajax_doSomething(xajax.getFormValues('someForm'));");<br /><br />return $objResponse-&gt;getXML();<br />}<br /><br /><br />?&gt;<br />&lt;?php<br />$xajax = new xajax();<br />//$xajax-&gt;debugOn();<br />$xajax-&gt;registerFunction("doSomething");<br />$xajax-&gt;registerFunction("hb");<br />$xajax-&gt;processRequests();<br />?&gt;<br />&lt;HTML&gt;<br />&lt;HEAD&gt;<br />&lt;?php $xajax-&gt;printJavascript(); ?&gt;<br />&lt;/HEAD&gt;<br /><br />&lt;BODY&gt;<br />&lt;form id='someForm'&gt;<br />&lt;table&gt;<br />&lt;tr&gt;<br />&lt;td&gt;username:<br />&lt;input type="text" name='user' id='user' /&gt;<br />&lt;/td&gt;<br />&lt;td&gt;password:&lt;input type="password" id='pwd' name='pwd' /&gt;&lt;/td&gt;<br />&lt;td&gt;&lt;input type='button' id='doIt' value='Do It' onClick="xajax_hb()"&gt;&lt;/input&gt;<br />&lt;/td&gt;&lt;/tr&gt;<br />&lt;/table&gt;<br />&lt;/form&gt;<br /><br />&lt;div id='result'&gt;<br />&lt;/div&gt;<br />&lt;/BODY&gt;<br />&lt;/HTML&gt;</span><br /><br />这个要注意的比较多<br />a）表单的元素必须有name属性，这个一定要注意，这是我痛苦了一天得到的结果，否则getFormValues函数将得不到表单数据。<br />b) doSomething($formData)函数中的参数$formData是一个数组元素，索引是表单元素的名称（属性name的值），其值是表单元素的值（属性value的值）<br />c） 如果debugon打开了，可能会出现死循环的警告窗口，目前还不知道原因。</font><img src ="http://www.blogjava.net/JRobot/aggbug/69490.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JRobot/" target="_blank">JRobot</a> 2006-09-13 22:25 <a href="http://www.blogjava.net/JRobot/articles/69490.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>xajax基础心得</title><link>http://www.blogjava.net/JRobot/articles/69489.html</link><dc:creator>JRobot</dc:creator><author>JRobot</author><pubDate>Wed, 13 Sep 2006 14:22:00 GMT</pubDate><guid>http://www.blogjava.net/JRobot/articles/69489.html</guid><wfw:comment>http://www.blogjava.net/JRobot/comments/69489.html</wfw:comment><comments>http://www.blogjava.net/JRobot/articles/69489.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JRobot/comments/commentRss/69489.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JRobot/services/trackbacks/69489.html</trackback:ping><description><![CDATA[
		<table border="0" cellpadding="4" cellspacing="1" width="100%">
				<tbody>
						<tr>
								<td style="background-color: rgb(255, 255, 255);" class="smalltxt" onmouseover="this.style.backgroundColor='#F8F8F8'" onmouseout="this.style.backgroundColor='#FFFFFF'" align="center">
										<div align="left">
												<br />
                          转自：http://spaces.msn.com/blackwoodk ... 2wpZwYtrg!169.entry
<br /><br />最近研究了一下ajax，最后选了xajax作为基本class
<br />参考站点：http://xajax.sourceforge.net
<br /><br />因为基本都是gb2312所以把xajax.inc.php里面的编码改了一下，不过老实说UTF-8不错：
<br />$this-&gt;xml = "&lt;?xml version="1.0" encoding="GB2312"?&gt;";
<br />重新封装了一下KaneXajax类，
<br />除此以外基本没怎么改动。
<br /><br />&lt;?php
<br />require_once(‘Smarty/Smarty.class.php‘);
<br />require_once(‘Xajax/xajax.inc.php‘);
<br />function myFunction($arg)
<br />{
<br />$objResponse = new xajaxResponse();
<br />$objResponse-&gt;addAssign("SomeElementId","innerHTML", $newContent);
<br />return $objResponse-&gt;getXML();
<br />}
<br />$Kanexajax = new KaneXajax();
<br />$Kanexajax-&gt;registerFunction("myFunction");
<br />$Kanexajax-&gt;processRequests();
<br />$KaneSMARTY = new KaneSmarty(); 
<br />$KaneSMARTY-&gt;assign(‘xajax_javascript‘, $xajax-&gt;getJavascript());
<br />$KaneSMARTY-&gt;display(myTEMPLATE);
<br />?&gt; 
<br />一个最基本的php就ok了，当然tpl里面&lt;{$xajax_javascript}&gt;要加到&lt;HEAD&gt;&lt;/HEAD&gt;之间
<br /><br />再说说基本的方法吧：
<br /><br />* addAssign($sTargetId,$sAttribute,$sData)
<br />设置$sTargetId元素的$sAttribute属性为$sData，常用的有div的innerHTML，input的value什么的。
<br /><br />$objResponse-&gt;addAssign("contentDiv","innerHTML","Some Text");
<br />$objResponse-&gt;addAssign("checkBox1","checked","true"); 
<br />* addAppend($sTargetId,$sAttribute,$sData)
<br />追加$sData到$sTargetId元素的$sAttribute属性上
<br /><br />$objResponse-&gt;addAppend("contentDiv","innerHTML","Some Text"); 
<br />* addPrepend($sTargetId,$sAttribute,$sData)
<br />预制$sTargetId元素的$sAttribute属性为$sData，老实说，没在实战中用过呢，呵呵
<br /><br />$objResponse-&gt;addPrepend("contentDiv","innerHTML","Some Text"); 
<br />* addReplace($sTargetId,$sAttribute,$sSearch,$sData)
<br />替换$sTargetId元素的$sAttribute属性中的$sSearch为$sData。
<br /><br />$objResponse-&gt;addReplace("contentDiv","innerHTML","text","&lt;strong&gt;text&lt;/strong&gt;"); 
<br />* addClear($sTargetId,$sAttribute)
<br />清空$sTargetId元素的$sAttribute属性
<br /><br />$objResponse-&gt;addClear("Input1","value"); 
<br />* addCreate($sParentId, $sTagname, $sId, $sType)
<br />创建$sParentId元素的一个新的子元素，其name为$sTagname，Id为$sId，类型为$sType
<br /><br />$objResponse-&gt;addCreate("form1","input", "pass", "password"); 
<br />* addRemove($sElementId)
<br />移除$sElementId元素
<br /><br />$objResponse-&gt;addRemove("div1"); 
<br />* addAlert($sMsg)
<br />弹出一个内容为$sMsg的提示框
<br /><br />$objResponse-&gt;addAlert("This is some text"); 
<br />* addScript($sJS)
<br />执行一段javascript
<br /><br />$objResponse-&gt;addScript("var txt = prompt(‘get some text‘);");
<br />$objResponse-&gt;addScript("window.location=""."demo.php?id=1"."";"); 
<br />这两天用PHP+SMARTY+XAJAX写了一些小东西，感觉上就是调试完全靠感觉，不过
<br />按照DB的debug，Smarty的debug，xajax的debugOn()，的步骤，一步步地测好再往下写会好很多
<br />因为，smarty已经够敏感，经常给你一张大白脸，而xajax更加敏感，任何的地方有一点小错误，他立刻完蛋，这样的女人娶回家真是挺可怕的，不过谁让她支持Smarty呢？
<br /><br />过两天再把改好的一些代码贴上来吧，感觉还有的优化</div>
								</td>
						</tr>
				</tbody>
		</table>
<img src ="http://www.blogjava.net/JRobot/aggbug/69489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JRobot/" target="_blank">JRobot</a> 2006-09-13 22:22 <a href="http://www.blogjava.net/JRobot/articles/69489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>十分钟学会 xajax </title><link>http://www.blogjava.net/JRobot/articles/69425.html</link><dc:creator>JRobot</dc:creator><author>JRobot</author><pubDate>Wed, 13 Sep 2006 09:38:00 GMT</pubDate><guid>http://www.blogjava.net/JRobot/articles/69425.html</guid><wfw:comment>http://www.blogjava.net/JRobot/comments/69425.html</wfw:comment><comments>http://www.blogjava.net/JRobot/articles/69425.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JRobot/comments/commentRss/69425.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JRobot/services/trackbacks/69425.html</trackback:ping><description><![CDATA[
		<p>
				<strong>译者按:</strong> xajax 最大的特点是他采用了xml response，这样我们可以用php来布置，处理异步传送数据之后，网页内容的更新。而这些操作其它的ajax 框架都是由js来完成的的。xajax 使我们只需要写一些php函数，就可以实现。<br />所有学好xajax的关健在于熟练掌握 xajaxresponse 类。<br /></p>
		<p>
				<strong>
						<br />tutorials:learn xajax in 10 minutes<br />教程:十分钟学会 xajax</strong>
				<br />
		</p>
		<p>
				<em>
						<br />using xajax in a php script</em>
				<br />一个使用的xajax的php脚本:<br /></p>
		<p>
				<em>
						<br />include the xajax class library:</em>
				<br />调用xajax类库:<br /></p>
		<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 src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">require_once</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">xajax.inc.php</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">); </span>
		</div>
		<p>
				<em>
						<br />instantiate the xajax object:</em>
				<br />实例化xajax对象</p>
		<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 src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #800080">$xajax</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> xajax(); </span>
		</div>
		<p>
				<em>
						<br />register the names of the php functions you want to be able to call through xajax:</em>
				<br />注册一个你想用xajax来调用的php函数名(与javascript中的函数名相对应 xajax_myfunction)</p>
		<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 src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #800080">$xajax</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">registerfunction(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">myfunction</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">); </span>
		</div>
		<p>
				<em>
						<br />write the php functions you have registered and use the xajaxresponse object to return xml commands from them:</em>
				<br />编写那个你刚刚已经注册的php函数，并从中用 xajaxresponse 对象来返回xml指令集</p>
		<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 src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> myfunction(</span>
				<span style="COLOR: #800080">$arg</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"> do some stuff based on $arg like query data from a database and<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    // put it into a variable like $newcontent<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    //对参数$arg做一些诸如：从数据库中获取数据后定义给$newcontent 变量的基本操作<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" />    // instantiate the xajaxresponse object<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    //实例化 xajaxresponse 对象</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> xajaxresponse();<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"> add a command to the response to assign the innerhtml attribute of<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    // the element with id="someelementid" to whatever the new content is<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    // 在响应实例中添加一个命令，用来将id为someelementid的innerhtml元素属性<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    // 变为任何新的内容.</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">addassign(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">someelementid</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">innerhtml</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$newcontent</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">return the xml response generated by the xajaxresponse object<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    //返回由 xajaxresponse 对象所生成的xml 响应</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">    </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">getxml();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} </span>
		</div>
		<p>
				<em>
						<br />before your script sends any output, have xajax handle any requests:</em>
				<br />在你脚本传送出任何东西前,xajax都要处理所有请求</p>
		<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 src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #800080">$xajax</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">processrequests(); </span>
		</div>
		<p>
				<em>
						<br />between your &lt;head&gt;&lt;/head&gt; tags, tell xajax to generate the necessary javascript:</em>
				<br />在该页的&lt;head&gt;和&lt;/head&gt;标签之间插入下列代码，使xajax实例可以自己生成所必需的js<span class="code"></span></p>
		<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 src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php </span>
				<span style="COLOR: #800080">$xajax</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">printjavascript(); </span>
				<span style="COLOR: #000000">?&gt;</span>
		</div>
		<p>
				<em>
						<br />call the function from a javascript event or function in your application:</em>
				<br />从你程序中的js 事件或函数调用之前你已经注册过的相对应函数</p>
		<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 src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">&lt;</span>
				<span style="COLOR: #800000">div </span>
				<span style="COLOR: #ff0000">id</span>
				<span style="COLOR: #0000ff">="someelementid"</span>
				<span style="COLOR: #0000ff">&gt;&lt;/</span>
				<span style="COLOR: #800000">div</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">button </span>
				<span style="COLOR: #ff0000">onclick</span>
				<span style="COLOR: #0000ff">="xajax_myfunction(someargument);"</span>
				<span style="COLOR: #0000ff">&gt;</span>
				<span style="COLOR: #000000"> </span>
		</div>
		<p>
				<em>
						<br />that's it. xajax takes care of most everything else. your biggest task is writing the php functions and returning xajax xml responses from them-- which is made extremely easy by the xajaxresponse class.<br /></em>只需这些步骤。其他的交由xajax 去处理吧。你最主要的任务只是编写php中的函数，只要使它们能返回xajax的xml响应就行了，而这步可以用xajaxresponse 类轻松解决。</p>
		<p>
				<em>
						<br />how do i update my content asynchronously?</em>
				<br />如何异步更新我的内容?</p>
		<p>
				<em>
						<br />perhaps the most unique feature of xajax is the xajaxresponse class. other ajax libraries require you to write your own callback handlers in javascript to process the data returned from an asynchronous request and to update the content. xajax, on the other hand, allows you to easily control your content from php. the xajaxresponse class allows you to create xml instructions to return to your application from your php functions. the xml is parsed by xajax message pump and the instructions tell xajax how to update the content and state of your application. the xajaxresponse class currently offers a number of useful commands, such as assign, which sets the specified attribute of an element in your page; append, which appends data to the end of the specified attribute of an element in your page; prepend, which prepends data to the beginning of the specified attribute of an element in your page; replace, which searches for and replaces data in the specified attribute of an element in your page; script, which runs the supplied javascript code; and alert, which shows an alert box with the supplied message text. <br /></em>xajax最独特的长处也许就是 xajaxresponse class了。其它的ajax库需要你亲自写用js写回调的句柄，来处理一个异步请求而且得到的数据，并更新其内容。另一方面，xajax只需你简单的控制好php的内容。然后通过xajaxresponse 类，使在你的php函数中创建xml指令返回给你的程序。xml将被 xajax的信息(pump)解析。其指令告知xajax将如何更新内容和你程序中的位置。现在xajaxresponse 已经提供了大量并有帮助的指令：<a href="http://www.flaspx.com/weblog/blog.php?bid=16" target="_blank"><font color="#002c99">http://www.flaspx.com/weblog/blog.php?bid=16</font></a>  (略...付上详细的xajaxresponse 类说明)</p>
		<p>
				<em>
						<br />a single xml response may contain multiple commands, which will be executed in the order they were added to the response. for example, let's say that a user clicks on a button in your application. the onclick event calls the javascript wrapper for a php function. that wrapper sends an asynchronous request to the server through xmlhttprequest where xajax calls the php function. the php function does a database lookup, some data manipulation, or serialization. you use the xajaxresponse class to generate an xajax xml response containing multiple commands to send back to the xajax message pump to be executed: <br /></em>一个单独xml响应可以包含多条命令，他们将依据加入响应的顺序来被执行。举个例子吧，让我们假设一个用户在你的程序中按下了一个按钮。这个按下的事件将调用被js封装好的php函数。这个封包通过 xmlhttprequest 发出了一个异步请求给服务器，让xajax调用php函数。这个php函数做了一个查询数据库，一些数据处理或排序的操作。而你要用 xajaxresponse 类来产出一个 xajax 的xml响应，它包含了多条命令。送给xajax 信息pump来执行:</p>
		<p>
				<span class="code">
				</span>
		</p>
		<p>
		</p>
		<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 src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> xajaxresponse();<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: #800080">$objresponse</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">addassign(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">myinput1</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">value</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$datafromdatabase</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">addassign(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">myinput1</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">style.color</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">red</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">addappend(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">mydiv1</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">innerhtml</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$datafromdatabase2</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">addprepend(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">mydiv2</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">innerhtml</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$datafromdatabase3</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">addreplace(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">mydiv3</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">innerhtml</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">xajax</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&lt;strong&gt;xajax&lt;/strong&gt;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">addscript(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">var x = prompt(\</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">enter your name\</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);</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: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$objresponse</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">getxml();<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>
		</div>
		<p>
				<em>
						<br />the xajax message pump would parse the xml message and perform the following: <br /></em>xajax信息pump将会解析下列xml信息，并执行以下操作: </p>
		<p>
				<em>
						<br />the value of the element with id myinput1 would be assigned to the data in $datafromdatabase.</em>
				<br />将变量$datafromdatabase赋值给id为myinput1的value元素。</p>
		<p>
				<em>
						<br />the color of the text in the element with id myinput1 would be changed to red. <br /></em>id为myinput1的字体颜色元素将被换成红色.</p>
		<p>
				<em>
						<br />the data in $datafromdatabase2 would be appended to the innerhtml of the element with id mydiv1.</em>
				<br />$datafromdatabase2,此数据将被追加到id为mydiv1的innerthml元素的结束部位</p>
		<p>
				<em>
						<br />the data in $datafromdatabase3 would be prepended to the innerhtml of the element with id mydiv2.</em>
				<br />$datafromdatabase3,此数据将被添加到id为mydiv2的innerthml元素的开始部位</p>
		<p>
				<em>
						<br />all occurrences of "xajax" in the innerhtml of the element with id mydiv3 would be replaced with "xajax"; making all of the instances of the word xajax appear bold. <br /></em>id为mydiv3的innerhtml元素中所有的 "xajax" 将被替换成 "xajax",使所有的xajax以粗体显示。</p>
		<p>
				<em>
						<br />a prompt would be displayed asking for the user's name and the value returned from the prompt would be placed into a javascript variable named x. <br /></em>会有一个输入框弹出，并询问用户姓名。从输入框取得的变量将转换成js变量并命名为x。<br /><em>all of this is implemented on the server side in the php function by forming and returning an xajax xml response.</em><br />所有这些组成了php函数在服务器端被执行，然后传回一个xml响应。</p>
<img src ="http://www.blogjava.net/JRobot/aggbug/69425.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JRobot/" target="_blank">JRobot</a> 2006-09-13 17:38 <a href="http://www.blogjava.net/JRobot/articles/69425.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Xajax中文手册</title><link>http://www.blogjava.net/JRobot/articles/69422.html</link><dc:creator>JRobot</dc:creator><author>JRobot</author><pubDate>Wed, 13 Sep 2006 09:26:00 GMT</pubDate><guid>http://www.blogjava.net/JRobot/articles/69422.html</guid><wfw:comment>http://www.blogjava.net/JRobot/comments/69422.html</wfw:comment><comments>http://www.blogjava.net/JRobot/articles/69422.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JRobot/comments/commentRss/69422.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JRobot/services/trackbacks/69422.html</trackback:ping><description><![CDATA[
		<div class="title">
				<h1>Xajax中文手册(第一版)</h1>
				<h2>
						<strong>日期：</strong>2006-02-13 17:02:00  <strong>点击：</strong>2678  <strong>作者：</strong>  <strong>来源：</strong></h2>
		</div>
		<div class="articlecontent">
				<div twffan="done">原文：http://xajax.sourceforge.net/</div>
				<div twffan="done">英文原版：Copyright © 2005 J. Max Wilson</div>
				<div twffan="done">简体中文翻译：HonestQiao(乔楚)/2005-12-7 17:23/(第一版)</div>
				<ul type="disc">
						<li>什么是xajax? 
</li>
						<li>xajax如何工作? 
</li>
						<li>为什么我要使用xajax代替其他PHP的Ajax库? 
</li>
						<li>如何在我的PHP脚本之中使用xajax? 
</li>
						<li>如何异步更新内容? 
</li>
						<li>如何异步处理表单数据? 
</li>
						<li>如何给xajax增加定制功能? 
</li>
						<li>我能在私有或者收费产品之中使用xajax吗?</li>
				</ul>
				<div align="left" twffan="done"> </div>
				<ul type="disc">
						<li>What is xajax? 
</li>
						<li>How does xajax work? 
</li>
						<li>Why should I use xajax instead of another Ajax library for PHP? 
</li>
						<li>How do I use xajax in my PHP script? 
</li>
						<li>How do I update my content asynchronously? 
</li>
						<li>How do I process form data asynchronously? 
</li>
						<li>How do I add custom functionality to xajax? 
</li>
						<li>May I use xajax in a proprietary product and charge for it?</li>
				</ul>
				<div align="left" twffan="done">
						<b>什么是xajax?</b>
				</div>
				<div align="left" twffan="done">Xajax是一个开源的 PHP 类库 它能够让你黏合HTML、CSS、JavaScript和PHP，轻而易举的开发功能强大、基于WEB的AJAX应用软件. 使用xajax开发的应用软件，无需重新调入页面，就能够异步调用服务器端的PHP函数和更新内容. </div>
				<div align="left" twffan="done">
						<b>What is xajax?</b>
				</div>
				<div align="left" twffan="done">xajax is an open source PHP class library that allows you to easily create powerful, web-based, Ajax applications using HTML, CSS, JavaScript, and PHP. Applications developed with xajax can asynchronously call server-side PHP functions and update content <i>without reloading the page</i>. </div>
				<div align="left" twffan="done"> </div>
				<div align="left" twffan="done">
						<b>xajax 如何工作?</b>
				</div>
				<div align="left" twffan="done">你的应用软件需要异步调用的PHP函数， xajax的PHP对象都生成了对应的封装好了的JavaScript函数. 当被调用时，封装的函数使用JavaScript的XMLHttpRequest对象与服务器异步通讯，调用xajax对象对应的PHP函数. 调用结束后, PHP函数由xajax返回一个xajax的XML响应传递给应用程序. XML响应包含了特定的指令和数据，他们可以被xajax的JavaScript消息分析器解析，并且被用于更新你的应用程序的内容.</div>
				<div align="left" twffan="done">
						<b>How does xajax work?</b>
				</div>
				<div align="left" twffan="done">The xajax PHP object generates JavaScript wrapper functions for the PHP functions you want to be able to call asynchronously from your application. When called, these wrapper functions use JavaScript's XMLHttpRequest object to asynchronously communicate with the xajax object on the server which calls the corresponding PHP functions. Upon completion, an xajax XML response is returned from the PHP functions, which xajax passes back to the application. The XML response contains instructions and data that are parsed by xajax's JavaScript message pump and used to update the content of your application.</div>
				<div align="left" twffan="done">
						<b>为什么我要使用xajax代替其他PHP的ajax库?</b>
				</div>
				<div align="left" twffan="done">你应该选择一个最是和你的项目需要的库.</div>
				<div align="left" twffan="done">xajax 提供了以下的功能, 它们使得ajax富有特色而又功能强大: </div>
				<div align="left" twffan="done">
						<b>Why should I use xajax instead of another Ajax library for PHP?</b>
				</div>
				<div align="left" twffan="done">You should choose whatever library will best meet the needs of your project.</div>
				<div align="left" twffan="done">xajax offers the following features that, together, make it unique and powerful: </div>
				<ul type="disc">
						<li>Xajax特殊的<b> XML 响应 / javascript 消息分析系统</b> 帮助你做到, 自动的处理函数返回的数据，按照PHP函数返回的指令更新内容或者状态. 因为xajax作了这些工作Because xajax does the work, 你不需要写javascript的回调处理函数. 
</li>
						<li>xajax's <b>unique XML response / javascript message-pump system</b> does the work for you, automatically handling the data returned from your functions and updating your content or state according to the instructions you return from your PHP functions. Because xajax does the work, you don't have to write javascript callback handler functions. 
</li>
						<li>Xajax<b>反对</b>将代码和数据紧密地杂糅在一起的主张, 并且保持xajax的代码从与他代码分离. 因为它是对象构造的, 你可以加上自己定制的功能给xajax去扩展xajaxResponse 类和使用addScript方法. 
</li>
						<li>xajax is <b>object oriented</b> to maintain tighter relationships between the code and data, and to keep the xajax code separate from other code. Because it is object oriented, you can <b>add your own custom functionality</b> to xajax by extending the xajaxResponse class and using the addScript() method. 
</li>
						<li>xajax 可以工作在 <b>Firefox</b>, Mozilla, 大部分基于 Mozilla 的浏览器, <b>Internet Explorer</b>, 和 <b>Safari</b>. 
</li>
						<li>xajax works in <b>Firefox</b>, Mozilla, probably other Mozilla based browsers, <b>Internet Explorer</b>, and <b>Safari</b>. 
</li>
						<li>除了更新元素的值和内含的HTML内容(innerHTML), xajax 还能用于更新样式(styles), css 类, 多选和单选按钮选择,甚至可以更新<b>任何元素的属性.</b></li>
						<li>In addition to updating element values and innerHTML, xajax can be used to update styles, css classes, checkbox and radio button selection, or nearly <b>any other element attribute.</b></li>
						<li>xajax <b>支持使用一维或者多维数组、关联数组(哈希数组)</b> 作为xajax函数的参数从javascript传送给PHP. 反之Additionally, 如果你传送一个javascript的对象给xajax函数，PHP函数将接受一个<b>描叙对象属性</b>的关联数组(哈希数组)<b>.</b></li>
						<li>xajax supports <b>passing single and multidimensional arrays and associative arrays</b> from javascript to PHP as parameters to your xajax functions. Additionally, if you pass a javascript object into an xajax function, the PHP function will receive an associative array representing the <b>properties of the object.</b></li>
						<li>xajax 提供了一种<b>简单的异步表单处理方式</b>. 使用 xajax.getFormValues() javascript 方法, 你可以轻而易举的在表单之中提交一个描绘值的数组作为参数传送到xajax异步处理函数: </li>
				</ul>
				<div align="left" twffan="done">xajax_processForm(xajax.getFormValues('formId');</div>
				<div align="left" twffan="done">. 它可以处理复杂的<b>input 元素名称</b> ，例如 "checkbox[][]" 或者 "name[first]" 产生的多维或者关联数组(哈希数组), 就是普通提交表单那样使用PHP的$_GET数组</div>
				<ul type="disc">
						<li>xajax provides <b>easy asynchronous Form processing</b>. By using the xajax.getFormValues() javascript method, you can easily submit an array representing the values in a form as a parameter to a xajax asynchronous function: </li>
				</ul>
				<div align="left" twffan="done">xajax_processForm(xajax.getFormValues('formId');</div>
				<div align="left" twffan="done">. It even works with <b>complex input names</b> like "checkbox[][]" and "name[first]" to produce multidimensional and associative arrays, just as if you had submitted the form and used the PHP $_GET array</div>
				<ul type="disc">
						<li>使用xajax你可以动态的发送附加的javascript作为请求的响应到你的应用软件中运行，而这就和动态的更新元素的属性一样方便. 
</li>
						<li>Using xajax you can <b>dynamically send additional javascript</b> to your application to be run in response to a request as well as dynamically update element attributes. 
</li>
						<li>Xajax会自动比较PHP函数返回的数据与你已经标记需要修改的元素属性. 只有当新的数据确实可以改变现有的属性，属性才会真的被更新. 这将可消除程序在一定时间间隔内更新与当前内容相同或者不同的内容而出现的明显的闪烁. 
</li>
						<li>xajax automatically compares the data returned from the PHP functions to the data that is already in the attribute of the element you have marked for change. The attribute is <b>only updated with the new data if it will actually change what is already in the attribute</b>. This <b>eliminates the flicker</b> often observed in applications that update content at a regular time interval with data which may or may not differ from extant content. 
</li>
						<li>每一个通过xajax简单注册的函数都可以有不同的请求方式. 所有的函数默认使用POST方式，除非你明确的指定使用GET方式. 如果使用GET请求，你必须非常明确的考虑它确实是你所需要的 
</li>
						<li>Each function registered to be accessible through xajax can have a <b>different request type</b>. All functions <b>default to use POST</b> unless GET is explicitly set. This is to encourage careful consideration of when to use GET requests 
</li>
						<li>如果没有指定URI，xajax将设法自动确定脚本的URI. Xajax的自动确定算法经过了充分的验证，确保在大部分HTTPS或者未知端口的HTTP服务器上也可以正常的工作<b>.</b></li>
						<li>If no request URI is specified, xajax tries to <b>autodetect the URL</b> of the script. The xajax autodetection algorithm is sophisticated enough that, on most servers, it will work under a <b>secure https:// protocol</b> as well as http:// and with <b>nonstandard ports.</b></li>
						<li>Xajax使用UTF8编码所有的请求和响应，以确保支持绝大部分的字符和语言. Xajax已经成功测试了多种不同的UNICODE字符，包括<b>Spanish, Russian, Arabic, and Hebrew</b></li>
						<li>xajax encodes all of its requests and responses in <b>UTF-8</b> so that it can support a wider range of characters and languages. xajax has been successfully tested with various unicode characters including <b>Spanish, Russian, Arabic, and Hebrew</b></li>
						<li>几乎所有xajax生成的javascript都可以通过动态的外部javascript包含到你的web程序之中. 当你在浏览器之中查看程序的源代码时，不会有JavaScript的函数定义混杂在HTML标记之中. 
</li>
						<li>Nearly all of the javascript generated by xajax is included into your web application through <b>dynamic external javascript</b>. When you view the source of your application in your browser, the markup will be <b>not cluttered by JavaScript function definitions</b>. 
</li>
						<li>Xajax可以使用在Smarty模板系统之中，仅仅需要创建一个smarty变量就可以包含xajax的javascript: </li>
				</ul>
				<div align="left" twffan="done">$smarty-&gt;assign('xajax_javascript', $xajax-&gt;getJavascript());</div>
				<div align="left" twffan="done">然后你可以使用在header模版之中使用 </div>
				<div align="left" twffan="done">{$xajax_javascript}</div>
				<div align="left" twffan="done">从而把xajax应用到你的站点.</div>
				<ul type="disc">
						<li>xajax can be used with the <b>Smarty templating system</b> by creating a variable in smarty that contains the xajax javascript: </li>
				</ul>
				<div align="left" twffan="done">$smarty-&gt;assign('xajax_javascript', $xajax-&gt;getJavascript());</div>
				<div align="left" twffan="done">Then you can use </div>
				<div align="left" twffan="done">{$xajax_javascript}</div>
				<div align="left" twffan="done">in your header template to use xajax on your site.</div>
				<div align="left" twffan="done">
						<b>如何在我的PHP脚本之中使用xajax?</b>
				</div>
				<div align="left" twffan="done">Xajax的设计是如此的富有特色，以至于不管是已有的web程序还是新的项目，它都能够被极其简单的部署和应用. 仅仅需要七步，你就可以在几乎任何PHP脚本之中加入xajax的强大功能: </div>
				<div align="left" twffan="done">
						<b>How do I use xajax in my PHP script?</b>
				</div>
				<div align="left" twffan="done">xajax is designed to be extremely easy to implement in both existing web applications as well as new projects. You can add the power of xajax to nearly any PHP script in seven easy steps: </div>
				<ol type="1">
						<li>包含xajax类库:</li>
				</ol>
				<div align="left" twffan="done">require_once("xajax.inc.php");</div>
				<ol type="1" start="2">
						<li>实例化xajax 对象:</li>
				</ol>
				<div align="left" twffan="done">$xajax = new xajax();</div>
				<ol type="1" start="3">
						<li>注册你需要通过xajax调用的PHP函数的名称:</li>
				</ol>
				<div align="left" twffan="done">$xajax-&gt;registerFunction("myFunction");</div>
				<ol type="1" start="4">
						<li>编写注册的PHP函数，并且在函数之中使用xajaxResponse 对象返回XML指令: </li>
				</ol>
				<div align="left" twffan="done">function myFunction($arg)</div>
				<div align="left" twffan="done">{</div>
				<div align="left" twffan="done">   // 对$arg做一些基本处理例如从数据库检索数据</div>
				<div align="left" twffan="done">   // 然后把结果赋值给变量，例如$newContent</div>
				<div align="left" twffan="done">   </div>
				<div align="left" twffan="done">   // 实例化xajaxResponse 对象</div>
				<div align="left" twffan="done">   $objResponse = new xajaxResponse();</div>
				<div align="left" twffan="done">   </div>
				<div align="left" twffan="done">   // 添加指令到响应之中，用于指派</div>
				<div align="left" twffan="done">   //指定元素(例如id="SomeElementId")的innerHTML属性的新的内容</div>
				<div align="left" twffan="done">   $objResponse-&gt;addAssign("SomeElementId","innerHTML", $newContent);</div>
				<div align="left" twffan="done">   </div>
				<div align="left" twffan="done">   //返回xajaxResponse 对象生成的XML响应</div>
				<div align="left" twffan="done">   return $objResponse-&gt;getXML();</div>
				<div align="left" twffan="done">}</div>
				<ol type="1" start="5">
						<li>在你的脚本输出任何信息之前，调用xajax用于接管请求:</li>
				</ol>
				<div align="left" twffan="done">$xajax-&gt;processRequests();</div>
				<ol type="1" start="6">
						<li>在页面的 &lt;head&gt;&lt;/head&gt; 标签之间, 告诉xajax生成所必需的JavaScript:</li>
				</ol>
				<div align="left" twffan="done">&lt;?php $xajax-&gt;printJavascript(); ?&gt;</div>
				<ol type="1" start="7">
						<li>在程序中，从JavaScript事件或者函数调用前面注册的函数: </li>
				</ol>
				<div align="left" twffan="done">&lt;div id="SomeElementId"&gt;&lt;/div&gt;</div>
				<div align="left" twffan="done">&lt;button onclick="xajax_myFunction(SomeArgument);"&gt;</div>
				<ol type="1">
						<li>Include the xajax class library:</li>
				</ol>
				<div align="left" twffan="done">require_once("xajax.inc.php");</div>
				<ol type="1" start="2">
						<li>Instantiate the xajax object:</li>
				</ol>
				<div align="left" twffan="done">$xajax = new xajax();</div>
				<ol type="1" start="3">
						<li>Register the names of the PHP functions you want to be able to call through xajax:</li>
				</ol>
				<div align="left" twffan="done">$xajax-&gt;registerFunction("myFunction");</div>
				<ol type="1" start="4">
						<li>Write the PHP functions you have registered and use the xajaxResponse object to return XML commands from them: 
</li>
						<li>function myFunction($arg) 
</li>
						<li>{ 
</li>
						<li>  // do some stuff based on $arg like query data from a database and 
</li>
						<li>  // put it into a variable like $newContent 
</li>
						<li>
						</li>
						<li>  // Instantiate the xajaxResponse object 
</li>
						<li>  $objResponse = new xajaxResponse(); 
</li>
						<li>
						</li>
						<li>  // add a command to the response to assign the innerHTML attribute of 
</li>
						<li>  // the element with id="SomeElementId" to whatever the new content is 
</li>
						<li>  $objResponse-&gt;addAssign("SomeElementId","innerHTML", $newContent); 
</li>
						<li>
						</li>
						<li>  //return the XML response generated by the xajaxResponse object 
</li>
						<li>  return $objResponse-&gt;getXML();</li>
				</ol>
				<div align="left" twffan="done">}</div>
				<ol type="1" start="19">
						<li>Before your script sends any output, have xajax handle any requests:</li>
				</ol>
				<div align="left" twffan="done">$xajax-&gt;processRequests();</div>
				<ol type="1" start="20">
						<li>Between your &lt;head&gt;&lt;/head&gt; tags, tell xajax to generate the necessary JavaScript:</li>
				</ol>
				<div align="left" twffan="done">&lt;?php $xajax-&gt;printJavascript(); ?&gt;</div>
				<ol type="1" start="21">
						<li>Call the function from a JavaScript event or function in your application: 
</li>
						<li>&lt;div id="SomeElementId"&gt;&lt;/div&gt;</li>
				</ol>
				<div align="left" twffan="done">&lt;button onclick="xajax_myFunction(SomeArgument);"&gt;</div>
				<div align="left" twffan="done"> </div>
				<div align="left" twffan="done">就这么简单. xajax 会处理其他所有的事情. 你所要做的主要工作就是编写PHP函数，然后从函数之中返回xajax的XML响应。而后者通过xajaxResponse类可以非常简单的生成.</div>
				<div align="left" twffan="done">That's it. xajax takes care of most everything else. Your biggest task is writing the PHP functions and returning xajax XML responses from them-- which is made extremely easy by the xajaxResponse class.</div>
				<div align="left" twffan="done"> </div>
				<div align="left" twffan="done">
						<b>如何异步更新内容?</b>
				</div>
				<div align="left" twffan="done">Xajax最富有特色的功能或许就是xajaxResponse类. 其他的Ajax库需要你自己编写JavaScript的回调句柄去处理一个异步请求返回的数据并更新内容. xajax, 从另外一个角度来说, 允许你使用PHP简单的控制内容. xajaxResponse 让你在PHP函数之中创建XML指令返回给你的程序. XML将被xajax的消息分析器解析，指令将告诉xajax如何更新程序的内容和状态. xajaxResponse类目前提供了以下指令:</div>
				<div align="left" twffan="done">
						<b>How do I update my content asynchronously?</b>
				</div>
				<div align="left" twffan="done">Perhaps the most unique feature of xajax is the xajaxResponse class. Other Ajax libraries require you to write your own callback handlers in JavaScript to process the data returned from an asynchronous request and to update the content. xajax, on the other hand, allows you to easily control your content from PHP. The xajaxResponse class allows you to create XML instructions to return to your application from your PHP functions. The XML is parsed by xajax message pump and the instructions tell xajax how to update the content and state of your application. The xajaxResponse class currently offers the following commands: </div>
				<ul type="disc">
						<li>
								<b>addAssign($sTargetId,$sAttribute,$sData)</b>
								<br />给命名为$sTargetId的元素的$sAttribute属性赋值$sData </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addAssign("contentDiv","innerHTML","Some Text");</div>
				<div align="left" twffan="done">$objResponse-&gt;addAssign("checkBox1","checked","true");</div>
				<ul type="disc">
						<li>
								<b>addAssign($sTargetId,$sAttribute,$sData)</b>
								<br />Assigns the $sAttribute of the element identified by $sTargetId to $sData</li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addAssign("contentDiv","innerHTML","Some Text");</div>
				<div align="left" twffan="done">$objResponse-&gt;addAssign("checkBox1","checked","true");</div>
				<ul type="disc">
						<li>
								<b>addAppend($sTargetId,$sAttribute,$sData)</b>
								<br />给命名为$sTargetId的元素的$sAttribute属性追加值$sData</li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addAppend("contentDiv","innerHTML","Some Text");</div>
				<ul type="disc">
						<li>
								<b>addAppend($sTargetId,$sAttribute,$sData)</b>
								<br />Appends $sData to the $sAttribute of the element identified by $sTargetId </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addAppend("contentDiv","innerHTML","Some Text");</div>
				<ul type="disc">
						<li>
								<b>addPrepend($sTargetId,$sAttribute,$sData)</b>
								<br />预备给命名为$sTargetId的元素的$sAttribute属性赋值$sData </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addPrepend("contentDiv","innerHTML","Some Text");</div>
				<ul type="disc">
						<li>
								<b>addPrepend($sTargetId,$sAttribute,$sData)</b>
								<br />Prepends $sData to the $sAttribute of the element identified by $sTargetId </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addPrepend("contentDiv","innerHTML","Some Text");</div>
				<ul type="disc">
						<li>
								<b>addReplace($sTargetId,$sAttribute,$sSearch,$sData)</b>
								<br />替换命名为$sTargetId的元素的$sAttribute属性的值之中的$sSearch为$sData </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addReplace("contentDiv","innerHTML","text","&lt;strong&gt;text&lt;/strong&gt;");</div>
				<ul type="disc">
						<li>
								<b>addReplace($sTargetId,$sAttribute,$sSearch,$sData)</b>
								<br />replaces all instances of $sSearch with $sData in the $sAttribute of the element identified by $sTargetId </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addReplace("contentDiv","innerHTML","text","&lt;strong&gt;text&lt;/strong&gt;");</div>
				<ul type="disc">
						<li>
								<b>addClear($sTargetId,$sAttribute)</b>
								<br />清空命名为$sTargetId的元素的$sAttribute属性的值 </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addClear("Input1","value");</div>
				<ul type="disc">
						<li>
								<b>addClear($sTargetId,$sAttribute)</b>
								<br />Clears the $sAttribute of the element identified by $sTargetId </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addClear("Input1","value");</div>
				<ul type="disc">
						<li>
								<b>addCreate($sParentId, $sTagname, $sId, $sType)</b>
								<br />在已经存在的命名为$sParentId的元素下添加一个名叫$sTagName的子元素，并且把他的id赋值为$sId，可选的类型赋值为 $sType. </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addCreate("form1","input", "pass", "password");</div>
				<ul type="disc">
						<li>
								<b>addCreate($sParentId, $sTagname, $sId, $sType)</b>
								<br />Adds a new $sTagName child element to an existing element identified by $sParentId, and assigns it the id $sId and the optional type $sType. </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addCreate("form1","input", "pass", "password");</div>
				<ul type="disc">
						<li>
								<b>addRemove($sElementId)</b>
								<br />从你的程序之中移除命名为$sElementId的元素</li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addRemove("div1");</div>
				<ul type="disc">
						<li>
								<b>addRemove($sElementId)</b>
								<br />Removes the element identified by $sElementId from your application </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addRemove("div1");</div>
				<ul type="disc">
						<li>
								<b>addAlert($sMsg)</b>
								<br />显示一个内容为 $sMsg 的警告框(JavaScript的Alert)</li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addAlert("This is some text");</div>
				<ul type="disc">
						<li>
								<b>addAlert($sMsg)</b>
								<br />Display an alert box with $sMsg </li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addAlert("This is some text");</div>
				<ul type="disc">
						<li>
								<b>addScript($sJS)</b>
								<br />执行JavaScript代码 $sJS (演示代码原文有误)</li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addScript("var txt = prompt('get some text');");</div>
				<ul type="disc">
						<li>
								<b>addScript($sJS)</b>
								<br />Execute the JavaScript code $sJS</li>
				</ul>
				<div align="left" twffan="done">$objResponse-&gt;addAlert("var txt = prompt('get some text');");</div>
				<div align="left" twffan="done"> </div>
				<div align="left" twffan="done">一个独立的XML响应可能包含多个指令, 他们将按照加入响应的顺序执行. 让我们用一个用户在你的程序之中点击按钮为例来进行说明. Onclick事件调用PHP函数对应的javascript封装.这个封装通过XMLHttpRequest发送异步请求到服务器给xajax调用PHP函数. PHP函数做了一次数据库查询, 处理了一些数据, 或者序列化. 然后你使用xajaxResponse类生成包含多个指令的xajax的XML响应 ，并回送给xajax的消息分析器执行: </div>
				<div align="left" twffan="done">A single XML response may contain multiple commands, which will executed in the order they were added to the response. For example, let's say that a user clicks on a button in your application. The onclick event calls the javascript wrapper for a PHP function. That wrapper sends an asynchronous request to the server through XMLHttpRequest where xajax calls the PHP function. The PHP function does a database lookup, some data manipulation, or serialization. You use the xajaxResponse class to generate an xajax XML response containing multiple commands to send back to the xajax message pump to be executed:</div>
				<div align="left" twffan="done">    $objResponse = new xajaxResponse();</div>
				<div align="left" twffan="done">    $objResponse.addAssign("myInput1","value",$DataFromDatabase);</div>
				<div align="left" twffan="done">    $objResponse.addAssign("myInput1","style.color","red");</div>
				<div align="left" twffan="done">    $objResponse.addAppend("myDiv1","innerHTML",$DataFromDatabase2);</div>
				<div align="left" twffan="done">    $objResponse.addPrepend("myDiv2","innerHTML",$DataFromDatabase3);</div>
				<div align="left" twffan="done">    $objResponse.addReplace("myDiv3","innerHTML","xajax","&lt;strong&gt;xajax&lt;/strong&gt;");</div>
				<div align="left" twffan="done">    $objResponse.addScript("var x = prompt("Enter Your Name");");</div>
				<div align="left" twffan="done">            </div>
				<div align="left" twffan="done">    return $objResponse-&gt;getXML();</div>
				<div align="left" twffan="done"> </div>
				<div align="left" twffan="done">$objResponse = new xajaxResponse();</div>
				<div align="left" twffan="done">    $objResponse.addAssign("myInput1","value",$DataFromDatabase);</div>
				<div align="left" twffan="done">$objResponse.addAssign("myInput1","style.color","red");</div>
				<div align="left" twffan="done">$objResponse.addAppend("myDiv1","innerHTML",$DataFromDatabase2);</div>
				<div align="left" twffan="done">$objResponse.addPrepend("myDiv2","innerHTML",$DataFromDatabase3);</div>
				<div align="left" twffan="done">$objResponse.addReplace("myDiv3","innerHTML","xajax","&lt;strong&gt;xajax&lt;/strong&gt;");</div>
				<div align="left" twffan="done">$objResponse.addScript("var x = prompt("Enter Your Name");");</div>
				<div align="left" twffan="done">return $objResponse-&gt;getXML();</div>
				<div align="left" twffan="done">xajax消息分析器将会解析XML消息，并执行以下工作: </div>
				<ol type="1">
						<li>id为myInput1的元素的值将被赋值为 $DataFromDatabase的数据. 
</li>
						<li>id为myInput1的元素的颜色将会变为red. 
</li>
						<li>$DataFromDatabase2的数据会被追加到id为myDiv1的元素innerHTML之中. 
</li>
						<li>$DataFromDatabase3的数据会被预先赋值给id为myDiv2的元素innerHTML之中. 
</li>
						<li>id为myDiv3的元素的innerHTML 之中所有的"xajax"将被替换为"&lt;strong&gt;xajax&lt;/strong&gt;"; 使得所有的单词 xajax 显示加粗. 
</li>
						<li>一个提示框将会显示，用来询问用户姓名，从提示框返回的值会被命名为x的javascript变量接收.</li>
				</ol>
				<div align="left" twffan="done">The xajax message pump would parse the XML message and perform the following: </div>
				<ol type="1">
						<li>The value of the element with id myInput1 would be assigned to the data in $DataFromDatabase. 
</li>
						<li>The color of the text in the element with id myInput1 would be changed to red. 
</li>
						<li>The data in $DataFromDatabase2 would be appended to the innerHTML of the element with id myDiv1. 
</li>
						<li>The data in $DataFromDatabase3 would be prepended to the innerHTML of the element with id myDiv2. 
</li>
						<li>All occurrences of "xajax" in the innerHTML of the element with id myDiv3 would be replaced with "&lt;strong&gt;xajax&lt;/strong&gt;"; making all of the instances of the word xajax appear bold. 
</li>
						<li>a prompt would be displayed asking for the user's name and the value returned from the prompt would be placed into a javascript variable named x.</li>
				</ol>
				<div align="left" twffan="done">所有这些都由构成的PHP函数在服务器端执行并返回xajax的XML响应.</div>
				<div align="left" twffan="done">All of this is implemented on the server side in the PHP function by forming and returning an xajax XML response.</div>
				<div align="left" twffan="done">
						<b>如何异步处理表单数据?</b>
				</div>
				<div align="left" twffan="done">Xajax使得异步处理表单数句非常非常的简单. xajax.getFormValues()方法会自动的从表单提取数据，并作为一个参数提交给xajax注册的PHP函数. </div>
				<div align="left" twffan="done">xajax.getFormValues() 仅仅需要一个参数, 可以是你需要处理得表单的id, 或者是一个实际的表单对象. 你也可以使用xajax.getFormValues作为一个参数给xajax 函数, 例如:</div>
				<div align="left" twffan="done">xajax_processFormData(xajax.getFormValues('formId'));</div>
				<div align="left" twffan="done">xajax 会生成一个与表单数据对应的请求字符串给xajax服务器解析，然后以一个与表单数据对应的数组传递给PHP函数，就想你提交表单使用PHP的$_GET数组那么简单.</div>
				<div align="left" twffan="done">Xajax可以处理类似普通多维数组或者联合数组(哈希数组)等形式的复杂输入名字. 例如, 如果一个表单有三个多选框(checkboxes)并且都命名为 "checkbox[]", 但是值分别为 "check1", "check2", 和 "check3", 然后使用 xajax.getFormValues 函数作为参数传递给xajax 函数, 则 PHP 函数会接受到一个如下的数组: </div>
				<div align="left" twffan="done">array (</div>
				<div align="left" twffan="done">  'checkbox' =&gt; </div>
				<div align="left" twffan="done">  array (</div>
				<div align="left" twffan="done">    0 =&gt; 'check1',</div>
				<div align="left" twffan="done">    1 =&gt; 'check2',</div>
				<div align="left" twffan="done">    2 =&gt; 'check3',</div>
				<div align="left" twffan="done">  ),</div>
				<div align="left" twffan="done">)</div>
				<div align="left" twffan="done">作为函数参数的数组的结构与传统意义上提交表单之后的$_GET数组的结构相同. 你可以访问数组之中的checkbox 的数据: $aFormData['checkbox'][0]</div>
				<div align="left" twffan="done">
						<b>How do I process form data asynchronously?</b>
				</div>
				<div align="left" twffan="done">xajax makes processing form data asynchronously extremely easy. The xajax.getFormValues() method can be used to automatically extract the data from a form and pass it as a parameter to a PHP function you have registered with xajax. </div>
				<div align="left" twffan="done">xajax.getFormValues() takes one argument, which can be either the id of the form you want to process, or the actual form object. You use xajax.getFormValues as a parameter to your xajax function, like this:</div>
				<div align="left" twffan="done">xajax_processFormData(xajax.getFormValues('formId'));</div>
				<div align="left" twffan="done">xajax generates a query string representing the form data which is parsed by the xajax server and passed to your PHP function as an array representing the form data, just as if you had submitted the form and used the PHP $_GET array.</div>
				<div align="left" twffan="done">xajax will even handle complex input names to generate multidimensional and associative arrays. For instance, if you have a form with three checkboxes and you give them all the name "checkbox[]", but different values like "check1", "check2", and "check3", and you use the xajax.getFormValues function as a parameter to your xajax function, the PHP function will receive and array that looks like this: </div>
				<div align="left" twffan="done">array (</div>
				<div align="left" twffan="done">  'checkbox' =&gt; </div>
				<div align="left" twffan="done">  array (</div>
				<div align="left" twffan="done">    0 =&gt; 'check1',</div>
				<div align="left" twffan="done">    1 =&gt; 'check2',</div>
				<div align="left" twffan="done">    2 =&gt; 'check3',</div>
				<div align="left" twffan="done">  ),</div>
				<div align="left" twffan="done">)</div>
				<div align="left" twffan="done">The array argument to your function mirrors the structure that the $_GET array would have if you were to submit the form traditionally. You can then access the checkbox data in the array like this: </div>
				<div align="left" twffan="done">$aFormData['checkbox'][0]</div>
				<div align="left" twffan="done">
						<b>如何给xajax增加定制功能?</b>
				</div>
				<div align="left" twffan="done">Xajax可以使用各种服加的用户定制功能进行扩展. 正因为xajax是完全面向对象的，并且可以使用xajaxResponse的addScript()方法，所以他具有无限扩展的可能. 你可以创建你自己的xajax响应类，来继承xajaxResponse 类以及它的方法，并加上你自己定制的响应. 让我们用一个定制的增加选择组合框(select combo boxes)选项的响应指令的例子来说明. 你可以象下面这样扩展xajaxResponse 类: </div>
				<div align="left" twffan="done">class myXajaxResponse extends xajaxResponse</div>
				<div align="left" twffan="done">{  </div>
				<div align="left" twffan="done">  function addAddOption($sSelectId, $sOptionText, $sOptionValue)  </div>
				<div align="left" twffan="done">  {  </div>
				<div align="left" twffan="done">    $sScript  = "var objOption = new Option('".$sOptionText."','".$sOptionValue."');";</div>
				<div align="left" twffan="done">    $sScript .= "document.getElementById('".$sSelectId."').options.add(objOption);";</div>
				<div align="left" twffan="done">    $this-&gt;addScript($sScript);</div>
				<div align="left" twffan="done">  }</div>
				<div align="left" twffan="done">}</div>
				<div align="left" twffan="done">现在, 取代xajaxResponse 对象的初始化, 把你自己的 myXajaxResponse 对象的初始化定义到你的 xajax PHP 函数之中: </div>
				<div align="left" twffan="done">$objResponse = new myXajaxResponse();</div>
				<div align="left" twffan="done">$objResponse-&gt;addAssign("div1", "innerHTML", "Some Text");  </div>
				<div align="left" twffan="done">$objResponse-&gt;addAddOption("select1","New Option","13");  </div>
				<div align="left" twffan="done"> </div>
				<div align="left" twffan="done">return $objResponse-&gt;getXML();</div>
				<div align="left" twffan="done">被调用时，这个方法将会发送需要的javascript到页面并执行. 当然你也有另外一种做法Alternatively, 你可以在你的程序之中创建一个如下的javascript函数: </div>
				<div align="left" twffan="done">&lt;script type="text/javascript"&gt;</div>
				<div align="left" twffan="done">function addOption(selectId,txt,val)</div>
				<div align="left" twffan="done">{</div>
				<div align="left" twffan="done">        var objOption = new Option(txt,val);</div>
				<div align="left" twffan="done">        document.getElementById(selectId).options.add(objOption);</div>
				<div align="left" twffan="done">}</div>
				<div align="left" twffan="done">&lt;/script&gt;</div>
				<div align="left" twffan="done">并且使用addScript() 调用这个方法: </div>
				<div align="left" twffan="done">$objResponse-&gt;addScript("addOption('select1','New Option','13');");</div>
				<div align="left" twffan="done">
						<b>How do I add custom functionality to xajax?</b>
				</div>
				<div align="left" twffan="done">xajax can be extended with all kinds of additional custom functionality. The extendability of xajax is made possible because it is object oriented, and by the addScript() method of the xajaxResponse class. You can create your own xajax response class that extends the xajaxResponse class and has all of the normal xajaxResponse methods, plus your own custom responses. For instance, let's say that you wanted to add a custom response command to add options to select combo boxes. You could extend the xajaxResponse class like this: </div>
				<div align="left" twffan="done">class myXajaxResponse extends xajaxResponse</div>
				<div align="left" twffan="done">{  </div>
				<div align="left" twffan="done">  function addAddOption($sSelectId, $sOptionText, $sOptionValue)  </div>
				<div align="left" twffan="done">  {  </div>
				<div align="left" twffan="done">    $sScript  = "var objOption = new Option('".$sOptionText."','".$sOptionValue."');";</div>
				<div align="left" twffan="done">    $sScript .= "document.getElementById('".$sSelectId."').options.add(objOption);";</div>
				<div align="left" twffan="done">    $this-&gt;addScript($sScript);</div>
				<div align="left" twffan="done">  }</div>
				<div align="left" twffan="done">}</div>
				<div align="left" twffan="done">Now, instead of instantiating an xajaxResponse object, you instantiate and use your myXajaxResponse object in your xajax PHP functions: </div>
				<div align="left" twffan="done">$objResponse = new myXajaxResponse();</div>
				<div align="left" twffan="done">$objResponse-&gt;addAssign("div1", "innerHTML", "Some Text");  </div>
				<div align="left" twffan="done">$objResponse-&gt;addAddOption("select1","New Option","13");  </div>
				<div align="left" twffan="done"> </div>
				<div align="left" twffan="done">return $objResponse-&gt;getXML();</div>
				<div align="left" twffan="done">This method would send the necessary javascript to the page when it was called and execute it. Alternatively, you could create a javascript function in your application: </div>
				<div align="left" twffan="done">&lt;script type="text/javascript"&gt;</div>
				<div align="left" twffan="done">function addOption(selectId,txt,val)</div>
				<div align="left" twffan="done">{</div>
				<div align="left" twffan="done">        var objOption = new Option(txt,val);</div>
				<div align="left" twffan="done">        document.getElementById(selectId).options.add(objOption);</div>
				<div align="left" twffan="done">}</div>
				<div align="left" twffan="done">&lt;/script&gt;</div>
				<div align="left" twffan="done">and call it with the addScript() method: </div>
				<div align="left" twffan="done">$objResponse-&gt;addScript("addOption('select1','New Option','13');");</div>
				<div align="left" twffan="done">
						<b>我能在私有或者收费产品之中使用xajax吗?</b>
				</div>
				<div align="left" twffan="done">简而言之: 能，只要你愿意.</div>
				<div align="left" twffan="done">xajax PHP 类库的发布遵循 GNU Lesser General Public License (LGPL).</div>
				<div align="left" twffan="done">
						<b>May I use xajax in a proprietary product and charge for it?</b>
				</div>
				<div align="left" twffan="done">In short: Yes, you may.</div>
				<div align="left" twffan="done">The xajax PHP class library is released under the GNU Lesser General Public License (LGPL).</div>
				<div align="left" twffan="done"> </div>
				<div align="left" twffan="done">简体中文手册版权所有 © 2005 HonestQiao(乔楚)</div>
		</div>
<img src ="http://www.blogjava.net/JRobot/aggbug/69422.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JRobot/" target="_blank">JRobot</a> 2006-09-13 17:26 <a href="http://www.blogjava.net/JRobot/articles/69422.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用Google Ajaxslt 生成首页新闻</title><link>http://www.blogjava.net/JRobot/articles/69405.html</link><dc:creator>JRobot</dc:creator><author>JRobot</author><pubDate>Wed, 13 Sep 2006 08:57:00 GMT</pubDate><guid>http://www.blogjava.net/JRobot/articles/69405.html</guid><wfw:comment>http://www.blogjava.net/JRobot/comments/69405.html</wfw:comment><comments>http://www.blogjava.net/JRobot/articles/69405.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JRobot/comments/commentRss/69405.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JRobot/services/trackbacks/69405.html</trackback:ping><description><![CDATA[给自己维护的一个小网站加个首页新闻，浏览器用 Ajax 或者 Ajah 从服务器取新闻异步的显示出来，同时提供 RSS 源供聚合器订阅。 <br /><br />XMLHTTPRequest 从上次做过一个手机模拟器后就再没碰过，这次在网上搜寻发现了一个好东西：<a href="http://www.scss.com.au/family/andrew/webdesign/xmlhttprequest/" target="_blank">http://www.scss.com.au/family/andrew/webdesign/xmlhttprequest/</a>，一个 Cross-Browser 的 XMLHttpRequest 实现，作者在创作共用条款（Creative Commons License）下发布这个库，只要你不移除脚本中作者的姓名和网址就可以自由使用，就用它了！下载 xmlhttprequest.js 以备后用。<br /><br />数据可以保存在数据库中也可以简单的写入到服务器的一个文件中，为了灵活起见我就在 MySQL 中新建一个表放站内新闻了，就这么几个字段：id、title、content、time。新闻录入和从数据库中取数据提供给 Ajax/Ajah 请求略。<br /><br />下面是客户端 XMLHTTPRequest 的代码：<br /><br />&lt;html&gt;&lt;head&gt;&lt;title&gt;首页新闻测试&lt;/title&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt;&lt;script type="text/javascript" src="xmlhttprequest.js"&gt;&lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;div id="News"&gt;新闻读取中……&lt;/div&gt;&lt;script type="text/javascript"&gt;var req = new XMLHttpRequest();if( req ){req.onreadystatechange = function(){var News = "新闻读取失败";try{if( req.readyState == 4 &amp;&amp; ( req.status == 200 || req.status == 304 ) )News = req.responseText;}catch(e){News = e.description;}document.getElementById( 'News' ).innerHTML = News;};req.open( 'GET', 'news.php' );req.send( null );}&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;<br /><br /><br /><br />这里唯一值得说明的就是 XMLHTTPRequest 默认是用 UTF-8 传递数据的，所以你的数据源最好也用 UTF-8 否则（因为我们这里客户端已经指定了要用 GB2312 了）得到的会是乱码，这在 IE 下会引发 JavaScript 错误，在 FireFox 下却没问题，所以我用 try 和 catch 把上面的代码包住了，免得测试的时候出现错误。如果想试试的话可以用下面的代码作为 news.php：<br /><br />&lt;?phpecho iconv( "GB2312", "UTF-8", "这就是新闻" );//echo "这就是新闻";?&gt;<br /><br /><br /><br />如果注释掉第一句而开放第二句的话不仅看到的是乱码，在 IE 下还会出现 -1072896748 错误。有意思的是 IE 好像还会缓存由 XMLHTTPRequest 收到的内容，而 FireFox 则不会，所以在测试中会出现刷新 IE 很多次看到的还是旧数据的问题，可以在程序里加上下面 4 句话解决这个问题： <br /><br />header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );header( "Cache-Control: no-cache, must-revalidate" );header( "Pragma: no-cache" );<br /><br /><br /><br />要将首页新闻提供给聚合器订阅就要将后台输入的新闻生成 RSS feed，RSS 2.0 的规范可以参考 <a href="http://feedvalidator.org/docs/rss2.html" target="_blank">http://feedvalidator.org/docs/rss2.html</a>，相应的中文翻译版本可以在 <a href="http://www.cpcwedu.com/Document/WEBOfficial/095447158.htm" target="_blank">http://www.cpcwedu.com/Document/WEBOfficial/095447158.htm</a> 找到。<br /><br />RSS 格式其实也是 XML 众多方言中的一种，所以也要以 开头，根节点的名称必须是 rss，符合 RSS 2.0 规范的 RSS 中这个 rss 节点要有一个 version="2.0" 的属性。rss 节点有一个名为 channel 的子节点，channel 就是一个频道。channel 有 3 个必要的子节点，分别为 title、link 和 description。以 Blog 为例，title 就是 Blog 的名字，link 是 Blog 的 URL 地址，而 description 是 Blog 的描述。<br /><br /><br /><br />channel 可以包含若干个 item 子节点，在 Blog 中每一个 item 就对应一篇 post，我们这里每一个 item 就是一篇新闻。item 的所有子节点均为可选，但至少要包含 title 和 description，由于新闻要有时间，所以我们再给它加上一个 pubDate 节点，下面就是一个符合 RSS 2.0 规范的 RSS 文件内容：<br /><br />&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;rss version="2.0"&gt;&lt;channel&gt;&lt;title&gt;The name of my site&lt;/title&gt;&lt;link&gt;<a href="http://www.mysite.com/" target="_blank">http://www.mysite.com</a>&lt;/link&gt;&lt;description&gt;Just for testing&lt;/description&gt;&lt;item&gt;&lt;title&gt;About&lt;/title&gt;&lt;description&gt;Hi, I'm 2ndboy. Welcome to my site!&lt;/description&gt;&lt;pubDate&gt;Sat, 07 Sep 2005 0:00:01 GMT&lt;/pubDate&gt;&lt;/item&gt;&lt;item&gt;&lt;title&gt;New service is out!&lt;/title&gt;&lt;description&gt;It's great for using.&lt;/description&gt;&lt;pubDate&gt;Sat, 21 Sep 2005 1:23:45 GMT&lt;/pubDate&gt;&lt;/item&gt;&lt;/channel&gt;&lt;/rss&gt;<br /><br /><br />从数据库中读取最新的新闻内容生成 RSS 的代码这里就不贴了，无非是一些字符串的拼接，当然了，你也可以用 PHP 的 XML DOM 接口来生成这个 RSS 内容。这样一来在网站上提供 RSS 订阅就搞定了。<br /><br />在做完 RSS 部分后我突然有了一个想法，为了给使用 Ajax 取数据的浏览器提供信息，服务器要针对 Ajax 的请求单独作些响应处理，那何不就让浏览器把我们前面已经生成了的 RSS 当作数据源来显示首页新闻呢？这似乎是个不错的想法，但 RSS 是个 XML 格式的文件，很显然，想达到这样的目的就要让客户端用 JavaScript 来解析 XML 文件并加以显示。<br /><br />为了用 JavaScript 来操控 XML，我决定使用 Google 的一个开源项目——AjaXSLT（<a href="http://goog-ajaxslt.sourceforge.net/" target="_blank">http://goog-ajaxslt.sourceforge.net/</a>），更多 Google 开源项目可以访问 <a href="http://code.google.com/" target="_blank">http://code.google.com/</a>。Google 提供的这个 AjaXSLT 项目用 JS 实现了一个 XML 的 DOM 接口和一个 XSLT 实现，下面把里面的几个主要文件做个简单介绍：<br /><br />misc.js：一些常量定义和 helper 函数，还有 log 的实现。dom.js：XML DOM 接口的 JS 实现，主要的函数是 xmlParse( XMLString )，调用成功后就可以用标准 DOM 方式来操控返回的 XDocument 了。<br /><br />xpath.js：XPath 的 JS 实现。<br /><br />xslt.js：XSLT 的 JS 实现，要用到里面的 xsltProcess( XML, XSLT )，给定 XML 和 XSLT 得到转换的结果。<br /><br />你可以只使用其中的 DOM 实现部分，而 dom.js 又依赖于 misc.js，所以要先载入 misc.js 再载入 dom.js。为了在首页上显示好看的新闻，我们要用 CSS 来打扮一下新闻的外观，所以要对新闻的数据组织方式有些要求，比如说要把得到的新闻最终组织成下面这个样子<br /><br />&lt;div id="News"&gt;&lt;div class="News"&gt;&lt;span class="Title"&gt;title&lt;/span&gt;&lt;span class="Time"&gt;time&lt;/span&gt;&lt;span class="Content"&gt;content&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;<br /><br />这样之后我们就可以事先写一些针对 #News 和 div.News 等等的规则来装扮首页新闻了。好了，下面看看用 JS 解析 RSS 的代码怎么写（当然，之前我们先要用 Ajax 取到 RSS 数据）： var News = "";var doc = xmlParse( rss );items = doc.getElementsByTagName( "item" );for( var i = 0; i &lt; items.length; i++ ){News += "&lt;div class='News'&gt;";title = items[i].getElementsByTagName( "title" );News += ( "&lt;span class='Title'&gt;" + title[0].firstChild.nodeValue + "&lt;\/span&gt;" );time = items[i].getElementsByTagName( "pubDate" );News += ( "&lt;span class='Time'&gt;" + time[0].firstChild.nodeValue + "&lt;\/span&gt;" );description = items[i].getElementsByTagName( "description" );News += ( "&lt;span class='Content'&gt;" + description[0].firstChild.nodeValue + "&lt;\/span&gt;" );News += "&lt;\/div&gt;";}document.getElementById('News').innerHTML = News;<br /><br /><br />好了，到现在为止我们的首页新闻就算完工了，但是既然 AjaXSLT 提供了 XSLT 的 JS 实现，我们拿来试试。先照着《XML 高级编程》写个 XSLT：<br /><br />&lt;?xml version="1.0"?&gt;&lt;xsl:stylesheet version="1.0" xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform" target="_blank">http://www.w3.org/1999/XSL/Transform</a>"&gt;&lt;xsl:template match="/"&gt;&lt;xsl:apply-templates select="//item"/&gt;&lt;/xsl:template&gt;&lt;xsl:template match="item"&gt;&lt;div class="News"&gt;&lt;xsl:apply-templates select="title"/&gt;&lt;xsl:apply-templates select="pubDate"/&gt;&lt;xsl:apply-templates select="description"/&gt;&lt;/div&gt;&lt;/xsl:template&gt;&lt;xsl:template match="title"&gt;&lt;span class="Title"&gt;&lt;xsl:value-of select="."/&gt;&lt;/span&gt;&lt;/xsl:template&gt;&lt;xsl:template match="pubDate"&gt;&lt;span class="Time"&gt;&lt;xsl:value-of select="."/&gt;&lt;/span&gt;&lt;/xsl:template&gt;&lt;xsl:template match="description"&gt;&lt;span class="Content"&gt;&lt;xsl:value-of select="."/&gt;&lt;/span&gt;&lt;/xsl:template&gt;&lt;/xsl:stylesheet&gt;<br /><br /><br /><br />我们上面的 JavaScript 代码还要把这个 XSLT 从服务器上取下来，之后一句话就可以搞定上面一堆 JS 代码才能完成的工作：document.getElementById('News').innerHTML = xsltProcess( xmlParse( rss ), xmlParse( xslt ) );<br /><br />OK，大功告成！注意，由于 XSLT 在转换时使用了 XPath，所以要先包含 xpath.js 再引用 xslt.js。<br /><img src ="http://www.blogjava.net/JRobot/aggbug/69405.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JRobot/" target="_blank">JRobot</a> 2006-09-13 16:57 <a href="http://www.blogjava.net/JRobot/articles/69405.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Google Ajaxslt 使用</title><link>http://www.blogjava.net/JRobot/articles/69403.html</link><dc:creator>JRobot</dc:creator><author>JRobot</author><pubDate>Wed, 13 Sep 2006 08:50:00 GMT</pubDate><guid>http://www.blogjava.net/JRobot/articles/69403.html</guid><wfw:comment>http://www.blogjava.net/JRobot/comments/69403.html</wfw:comment><comments>http://www.blogjava.net/JRobot/articles/69403.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/JRobot/comments/commentRss/69403.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/JRobot/services/trackbacks/69403.html</trackback:ping><description><![CDATA[
		<p>先去下载google ajaxslt的源码包</p>
		<p>1、用xmlhttprequest从服务器获得xml数据放于id="xml"的div中</p>
		<p>也可以从各种封装的xmlhttprequest框架中直接获得xml，这种方式更好一些</p>
		<p>2、对应xsl放置于id="xslt"的div中</p>
		<p>3、通过Ajaxslt组合成html，结果将显示于id="htmldisplay"的div中</p>
		<p>加载如下js</p>
		<pre>  &lt;script src="../misc.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script src="../dom.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script src="../xpath.js" type="text/javascript"&gt;&lt;/script&gt;  &lt;script src="../xslt.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
		<p>然后</p>
		<pre>  var xml = xmlParse(el('xml').value);  var xslt = xmlParse(el('xslt').value);  var html = xsltProcess(xml, xslt);  document.getElementById('html').value = html;  document.getElementById('htmldisplay').innerHTML = html;</pre>
		<p>很简单就完成了xml到html的转化，而xpath/xsl的强大功能使得我们可以非常更方面的处理xml数据</p>
		<p>备注:</p>
		<p>misc.js：一些常量定义和 helper 函数，还有 log 的实现。</p>
		<p>dom.js：XML DOM 接口的 JS 实现，主要的函数是 xmlParse( XMLString )，调用成功后就可以用标准 DOM 方式来操控返回的 XDocument 了。</p>
		<p>xpath.js：XPath 的 JS 实现。</p>
		<p>xslt.js：XSLT 的 JS 实现，要用到里面的 xsltProcess( XML, XSLT )，给定 XML 和 XSLT 得到转换的结果。</p>
<img src ="http://www.blogjava.net/JRobot/aggbug/69403.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/JRobot/" target="_blank">JRobot</a> 2006-09-13 16:50 <a href="http://www.blogjava.net/JRobot/articles/69403.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>