Thinkphpajaxreturn returns data-php Tutorial

Source: Internet
Author: User
Thinkphpajaxreturn returns data problems thinkphp is really difficult to use, there are always problems, why thinkphp & nbsp; ajaxreturn & nbsp; returns a json string instead of a json object. Local is the returned object, the server is the returned string, solve ...... Thinkphp ajaxreturn returns data

Thinkphp is really difficult to use. it is always a problem. Why does thinkphp ajaxreturn return a json string instead of a json object. Local is the returned object, the server is the returned string, solve ......

Share:


------ Solution --------------------
Json string? What is the concept?
------ Solution --------------------
It should be something that can be controlled.

I have never used this framework, eva or JSON. parse.
------ Solution --------------------
Reference:
Quote: reference:

It should be something that can be controlled.

I have never used this framework, eva or JSON. parse.


I know this, but why is it different between the local server and the server? is it a server configuration problem? it is impossible to use two sets of code locally and on the server?


The server configuration does not matter. does thinkphp have this configuration?
------ Solution --------------------
LZ. It is recommended that you go to the official THINKPHP forum for more efficient consultation...
------ Solution --------------------
DataType: 'json'


------ Solution --------------------
Reference:
DataType: 'json'


He knows this.
------ Solution --------------------
Before you convert it to json, you can view the output result set.
------ Solution --------------------
Http transmits all text. why object?
Json itself is a data representation in text format. it is changed to js object only after interpretation and execution by the js engine.
------ Solution --------------------
Your #3 json data string has been correctly returned
So why is the string not converted into an object?
This is related to the default return header of your server, and of course also to the browser you are using.
You can output headers that declare the json data type before return.
You can also determine whether to perform another conversion by determining the data type in js.
Of course, the above discussion is based on the fact that your program has not changed.

In addition, thinkphp cannot be blamed, because thinkphp cannot predict which browsers will be less humane. it is rigid to interpret data according to the http header.

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.