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.