Thinkphp really use the wrong, old problems, why thinkphp Ajaxreturn returned is a JSON-formatted string, not a JSON object. Local is the return object, the server is the return string, solve ...
Reply to discussion (solution)
No-nobody ...
A string in JSON format? What's the concept?
A string in JSON format? What's the concept?
Local alert-out data
On the server, alert comes out of the
There should be a place to control it.
Don't use this frame yourself Eva or json.parse a bit
There should be a place to control it.
Don't use this frame yourself Eva or json.parse a bit
This I know, but the local and server why is not the same, is not a server configuration problem, it is not possible to use local and server two sets of code AH?
There should be a place to control it.
Don't use this frame yourself Eva or json.parse a bit
This I know, but the local and server why is not the same, is not a server configuration problem, it is not possible to use local and server two sets of code AH?
Server configuration should not have this relationship ah, thinkphp have this setting?
Lz. Suggest you go to thinkphp Official forum consultation is more efficient ...
DataType: ' JSON '
DataType: ' JSON '
He should know that.
Before you convert to JSON, look at the output result set.
HTTP is the text that transmits, what object does it come from?
JSON itself is a text format of the data representation, only through the JS engine to explain the execution will only become JS object
You #3 indicate that the JSON data string has been returned correctly.
So why is the string of figure two not being converted to an object?
This is related to the default return header of your server and, of course, to the browser you are using.
You can output the header that declares the JSON data type before returning
You can also decide whether you need to make a conversion by judging the data type in JS.
Of course, the discussion above is based on the lack of change in your program.
In addition, this can not blame thinkphp, because thinkphp can not predict which browsers will be so impersonal, rigid HTTP header to interpret the data
In conclusion, the knot has been pasted,
The first possible problem is in: thinkphp encapsulated JSON return object, some browsers do not support, so do not use the official method
The second problem is: Our company colleagues use the development environment is not the same, the system is different, some files produced a BOM problem, resulting in the Ajax return value more space
I also have multiple spaces, egg pain