Static page call PHP to get data and format display

Source: Internet
Author: User
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 '),
);
?>












  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.