protected function ajaxReturn($data,$info='',$status=1,$type='') {
$result = array();
$result['status'] = $status;
$result['statusCode'] = $status; // zhanghuihua@msn.com
$result['navTabId'] = $_REQUEST['navTabId']; // zhanghuihua@msn.com
$result['rel'] = $_REQUEST['rel']; // zhanghuihua@msn.com
$result['callbackType'] = $_REQUEST['callbackType']; // zhanghuihua@msn.com
$result['forwardUrl'] = $_REQUEST['forwardUrl']; // zhanghuihua@msn.com
$result['confirmMsg'] = $_REQUEST['confirmMsg']; // zhanghuihua@msn.com
$result['message'] = $info; // zhanghuihua@msn.com
$result['info'] = $info;
$result['data'] = $data;
//扩展ajax返回数据, 在Action中定义function ajaxAssign(&$result){} 方法 扩展ajax返回数据。
if(method_exists($this,'ajaxAssign'))
$this->ajaxAssign($result);
if(empty($type)) $type = C('DEFAULT_AJAX_RETURN');
if(strtoupper($type)=='JSON') {
// 返回JSON数据格式到客户端 包含状态信息
header('Content-Type:text/html; charset=utf-8');
exit(json_encode($result));
}elseif(strtoupper($type)=='XML'){
// 返回xml格式数据
header('Content-Type:text/xml; charset=utf-8');
exit(xml_encode($result));
}elseif(strtoupper($type)=='EVAL'){
// 返回可执行的js脚本
header('Content-Type:text/html; charset=utf-8');
exit($data);
}else{
// TODO 增加其它格式
}
}
需要改动TP的核心一点核心代码,或者在其子类中重写.
核心库中的Action.class.php
Line:290
Ajax跳转函数,修改$result数组内容。