Analysis of problems encountered in dwz+thinkphp development _php Example

Source: Internet
Author: User
Tags php template codeigniter zend framework

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.