dwz与Tp结合

protected function ajaxReturn($data,$info='',$status=1,$type='') {
         $result  =  array();
         $result['status']  =  $status;
         $result['statusCode']  =  $status;	// [email protected]
         $result['navTabId']  =  $_REQUEST['navTabId'];	// [email protected]
         $result['rel']  =  $_REQUEST['rel'];	// [email protected]
         $result['callbackType']  =  $_REQUEST['callbackType'];	// [email protected]
         $result['forwardUrl']  =  $_REQUEST['forwardUrl'];	// [email protected]
         $result['confirmMsg']  =  $_REQUEST['confirmMsg'];	// [email protected]
         $result['message'] =  $info; // [email protected]
         $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数组内容。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章