I first use SQL to query the data in the database for json data input in PHP, then traverse the data, and finally use json_encode to output the data. The result output is not of the json type. could you please kindly advise, I am very grateful for the solution!
Reply to discussion (solution)
That is the json data, which is not of the json type.
The result you output is of the json type, but it is a bit problematic if you look at it like this. you just need to go to Baidu online json formatting and put your data in it for formatting, however, this data does not affect your query results, but is only a json display problem.
The result looks like json, but I use ajax for parsing in js. The result is as follows:
1. I write datatype as json in ajax, and no result can be obtained.
2. I comment out datatype and output data to get a string.
So I cannot understand it here.
Where did this come from? Is it json?
Put
The result looks like json, but I use ajax for parsing in js. The result is as follows:
1. I write datatype as json in ajax, and no result can be obtained.
2. I comment out datatype and output data to get a string.
So I cannot understand it here.
This is because you still have HTML code on this page, so you add this exit in echo $ phptest; exit; to stop the output. remember not to use php to output the HTML code before.
Thank you! the problem has been solved.