Static page call PHP get data re-format display
We now have some PHP code that calls the relevant interface to return the JSON data. Now I want to implement PHP in HTML and output the returned data to HTML. Do you think this is realistic? (Note that the PHP section simply returns the JSON data, rather than writing something like document.write)
For example, the PHP interface will return a JSON data, I want the HTML to display a table to display the content.
I'm a client developer, and I know a little bit about the fur of the front. This is done because the original browser to open the server to do some of the pages, but a few pages of the performance is particularly bad and no one can tune (said to use a very advanced framework), so I now come up with the whole method.
------to solve the idea----------------------
The page to be executed must be the end of. PHP to parse PHP, and the logic to execute PHP Wrap it up.
After obtaining the JSON data, Json_decode ($json, True); An array that can be printed out to see
Embed the value of the array where you want it to appear, such as:
------to solve the idea----------------------
Get the data through Ajax and embed it in the page.
------to solve the idea----------------------
Use Ajax to call the PHP interface where you return the JSON data, and then use JS to parse the JSON to display on the page
------to solve the idea----------------------
Use Ajax to call the PHP interface where you return the JSON data, and then use JS to parse the JSON to display on the page
------to solve the idea----------------------
A simple example, see below.
$result = Array (
Array (' name ' = ' fdipzone ', ' gender ' = ' male '),
Array (' name ' = ' Tom ', ' gender ' = ' male '),
Array (' name ' = ' Lucy ', ' gender ' = ' female '),
);
?>