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數組內容。


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