This paper analyzes the problems encountered in the development of dwz+thinkphp. Share to everyone for your reference, specific as follows:
The thinkphp version I'm using now is 3.1.3.
The J-ui DWZ version looks like 1.4.
When I encountered such a problem in the process of project development,
When I am performing AJAX operations in the background, Success,error cannot successfully return the message, but instead returns an error message like object.
It's been a long time to find out if it's a version of the problem, the new version of Thinkphp's Ajax technology in DWZ
So I changed the Ajaxreturn function in Action.class.php to
protected function Ajaxreturn ($data, $type = ') {if (Func_num_args () >2) {//compatible before 3.0 usage $args = func_get_a
RGS ();
Array_shift ($args);
$info = Array ();
$info [' data '] = $data;
$info [' info '] = array_shift ($args);
$info [' status '] = Array_shift ($args);
$data = $info;
$type = $args? Array_shift ($args): '; /////greater than the original--$data [' statusCode '] = 1; $data [' navtabid '] = $_request[' navtabid '];//$data [' rel '] = $_request[' rel ']; $data [' callbacktype '] = $_request[' Callbacktype ']; $data [' forwardurl '] = $_request[' Forwardurl ']; $data [' confirmmsg '] = $_request[' confirmmsg '];//$data [' message '] = $data [' info '];
840206883@qq.com//More original additions--//if (empty ($type)) $type = C (' Default_ajax_return '); Switch (Strtoupper ($type)) {case ' JSON '://return JSON data format to client containing state information header (' content-type:application/ Json
Charset=utf-8 '); Exit (json_enCode ($DATA));
Case ' XML '://return header of data in XML format (' Content-type:text/xml; Charset=utf-8 ');
Exit (Xml_encode ($data));
Case ' JSONP '://returns JSON data format to client containing state information header (' Content-type:application/json; Charset=utf-8 '); $handler = Isset ($_get[c (' Var_jsonp_handler ')])?
$_get[c (' Var_jsonp_handler ')]: C (' Default_jsonp_handler '); Exit ($handler. '
('. Json_encode ($data); ');
Case ' EVAL '://Return executable JS script header (' content-type:text/html charset=utf-8 ');
Exit ($DATA);
Default://To extend other return format data tag (' Ajax_return ', $data);
}
}
More interested readers of thinkphp related content can view the website topic: "thinkphp Introductory Course", "thinkphp template Operation Skill Summary", "thinkphp Common Method Summary", "The CodeIgniter Introductory Course", "CI ( CodeIgniter) Framework Advanced tutorials, introductory tutorials for the Zend framework Framework, Smarty Templates Primer tutorial, and PHP template technology summary.
I hope this article will help you with the PHP program design based on thinkphp framework.