The type of data returned to Ajax in PHP is a bit confusing for JSON
This post was last edited by u013037779 on 2014-12-06 07:18:06
I am just about json_encode () How to use it is not good
For example, this is the JSON data to be transmitted in the Controller.
If I write Json_encode directly ($a);
This way, the receiving end to row here old error
I tried to use Window.alert (), to prove that the server had returned the data, but that the data was a series of HTML code that didn't know where it came from, not the data I wanted.
Ask how this should be written in Json_encode ();
In addition, if you are returning a 2-dimensional array from the database, how do I write it? For example, I queried some of his column values from the database by name.
I've encapsulated these values into 2-dimensional arrays. How can I be affected by using Json_encode to provide code
------to solve the idea----------------------
From the usage of row.city.length.
Your PHP program should only output {"City": ["Tianjin", "Wuhan", "Changsha", "Guangzhou"]} such content, if more things, it can not be converted to JS object
$a = Array ("Tianjin", "Wuhan", "Changsha", "Guangzhou");
echo json_encode (Array (' city ' = $a));