Call PHP to obtain data on the static page and then format the display.

Source: Internet
Author: User
The static page calls PHP to get the data and then format it to display that we already have some PHP code. you can call related interfaces to return JSON data. I want to adjust PHP in HTML and output the returned data to HTML. Is this a reality? (Note: The PHP part only returns JSON data, rather than writing documents. Write)

For example, if you call the PHP interface, a JSON data is returned. I want a table in HTML to display the data.

I am a client developer and have some knowledge about front-end. This is because the embedded browser is used to open several pages on the server, but the performance of several pages is particularly bad and nobody can tune them (it is said that a very advanced framework is used ), so now I have come up with the entire solution.


Reply to discussion (solution)

The executed page must end with. php to parse php. The php logic should be used for execution. Pack
After json data is obtained, json_decode ($ json, true) is an array, which can be printed for a moment.
Embed the value of the array into the display area, for example:

Get data through ajax and embed it into the page.

Use ajax to call the php interface for returning json data, and then parse json in js to display on the page

Use ajax to call the php interface for returning json data, and then parse json in js to display on the page

For a simple example, refer.

 'Fdipregion', 'gender' => 'male'), array ('name' => 'Tom ', 'gender' => 'male '), array ('name' => 'Lucy ', 'gender' => 'female'),);?>   
   New Document      

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.