Thinkphpajaxreturn returns data problems thinkphp is really not easy to use, there is always a problem, why thinkphp ajaxreturn returns a json string, not a json object. Local is the returned object, the server is the returned string, solve ......
Reply to discussion (solution)
No one cares ......
Json string? What is the concept?
Json string? What is the concept?
Data generated locally using alert
On the server, What alert comes out is
It should be something that can be controlled.
I have never used this framework, eva or JSON. parse.
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?
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?
LZ. It is recommended that you go to the official THINKPHP forum for more efficient consultation...
DataType: 'json'
DataType: 'json'
He knows this.
Before you convert it to json, you can view the output result set.
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.
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.
In conclusion, the Post is closed,
The first possible problem is: json returned objects encapsulated by thinkphp are not supported by some browsers, so this method is not required.
The second problem is: our colleagues in the company use different development environments and different systems. some files generate bom problems, resulting in more spaces in the ajax return values.
I also have multiple spaces, causing egg pain.