xajax基础心得 转自:http://spaces./blackwoodk ... 2wpZwYtrg!169.entry 最近研究了一下ajax,最后选了xajax作为基本class 参考站点:http://xajax. 因为基本都是gb2312所以把xajax.inc.php里面的编码改了一下,不过老实说UTF-8不错: $this->xml = "<?xml version=\"1.0\" encoding=\"GB2312\"?>"; 重新封装了一下KaneXajax类, 除此以外基本没怎么改动。 WEB CODE [Copy to clipboard]
<?php 再说说基本的方法吧: * addAssign($sTargetId,$sAttribute,$sData) 设置$sTargetId元素的$sAttribute属性为$sData,常用的有div的innerHTML,input的value什么的。 WEB CODE [Copy to clipboard]
$objResponse->addAssign("contentDiv","innerHTML","Some Text"); 追加$sData到$sTargetId元素的$sAttribute属性上 WEB CODE [Copy to clipboard]
$objResponse->addAppend("contentDiv","innerHTML","Some Text"); 预制$sTargetId元素的$sAttribute属性为$sData,老实说,没在实战中用过呢,呵呵 WEB CODE [Copy to clipboard]
$objResponse->addPrepend("contentDiv","innerHTML","Some Text"); 替换$sTargetId元素的$sAttribute属性中的$sSearch为$sData。 WEB CODE [Copy to clipboard]
$objResponse->addReplace("contentDiv","innerHTML","text","<strong>text</strong>"); 清空$sTargetId元素的$sAttribute属性 WEB CODE [Copy to clipboard]
$objResponse->addClear("Input1","value"); 创建$sParentId元素的一个新的子元素,其name为$sTagname,Id为$sId,类型为$sType WEB CODE [Copy to clipboard]
$objResponse->addCreate("form1","input", "pass", "password"); 移除$sElementId元素 WEB CODE [Copy to clipboard]
$objResponse->addRemove("div1"); 弹出一个内容为$sMsg的提示框 WEB CODE [Copy to clipboard]
$objResponse->addAlert("This is some text"); 执行一段javascript WEB CODE [Copy to clipboard]
$objResponse->addScript("var txt = prompt(‘get some text‘);"); 按照DB的debug,Smarty的debug,xajax的debugOn(),的步骤,一步步地测好再往下写会好很多 因为,smarty已经够敏感,经常给你一张大白脸,而xajax更加敏感,任何的地方有一点小错误,他立刻完蛋,这样的女人娶回家真是挺可怕的,不过谁让她支持Smarty呢? 过两天再把改好的一些代码贴上来吧,感觉还有的优化。 |
|