一种是利用php生成xml 格式,然后用xmlhttp.responseXml
另一种是直接php生成出数据 用xmlhttp.responseText
其实这上面两个没有本质的区别,只是说js的http请求返回的数据格式是定义为那种形式,以下的都是可以返回的数据格式,
responseBody 将回应信息正文以unsigned byte数组形式返回.只读
responseStream 以Ado Stream对象的形式返回响应信息。只读
responseText 将响应信息作为字符串返回.只读
responseXML 将响应信息格式化为Xml Document对象并返回,只读 只是你js的http请求后的数据的处理的差异,ajax的大致过程都是
1. 触发事件,
2. 执行事情处理程序,通过new xmlHttp对象,发出 http请求服务端程序
3. 服务端程序执行完毕通知客户端(浏览器)
4. 客户端(浏览器) 执行call function 获取返回的信息
生成xml 跟直接生成数据除了js接收形式不一样,其他的没差别吗? 譬如效率啥的?
感觉ajax对js要求很高,我看那代码看的费劲,js菜,没办法,xml ajax smarty 是我要熟悉的三个东西,都是刚接触啊,唉 看的头大 多 、乱另外求php类的代码 希望哪个朋友能贴点类的代码规范写法 或描述下也可以
没权发言...
<?PHP
/**
* PHP versions 5
*
* @filesource
* @copyright Copyright (c) 2007, ifensi Software Foundation, Inc.
* @package eshop
* @subpackage admin
* @version $Revision: 1 $
* @author $Author$
* @lastmodified $LastChangedDate$
*/
class Goods extends Model
{
public function __construct($index=0)
{
parent::__construct($index);
// ...
}
/**
* @todo 取资源的列表
* @param (int)$pPage 当前页码
* (int)$pAmount 分页数
* (string)$pWhere 多个条件复合的Where 条件的sql语句(不包含where)
* (string)$pFields 要取的字段名串
* (string)$pOrderBy 排序的条件(不包含order by)
* @return (array)
*/
public function getList( $pPage=-1, $pAmount=50, $pWhere='', $pFields='*', $pOrderBy=' id DESC' )
{
// ...
}
}
?>
我喜欢写成
class Goods extends Model{
。。
}
呵呵 昨天忘记结贴了