thinkphp Ajaxreturn Return Data problem
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 ...
Share to:
------Solution--------------------
A string in JSON format? What's the concept?
------Solution--------------------
There should be a place to control it.
Don't use this frame yourself Eva or json.parse a bit
------Solution--------------------
References:
Quote: References:
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?
------Solution--------------------
Lz. Suggest you go to thinkphp Official forum consultation is more efficient ...
------Solution--------------------
DataType: ' JSON '
------Solution--------------------
Reference:
dataType: ' JSON '
He should know that.
------Solution--------------------
Before you convert to JSON, look at the output result set.
------Solution--------------------
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
------Solution--------------------
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