How do React and php work together? Get data using ajax?

WBOY
Release: 2016-08-04 09:19:29
Original
1348 people have browsed it

Use react as the front end, and php is responsible for obtaining data. Both use ajax to transfer data.
This way, after rendering the page, the user can perform subsequent operations.
However, if the first rendering page is loaded with ajax, it will feel a bit slower.
Is there any good solution?

Reply content:

Use react as the front end, and php is responsible for obtaining data. Both use ajax to transfer data.
This way, after rendering the page, the user can perform subsequent operations.
However, if the first rendering page is loaded with ajax, it will feel a bit slower.
Is there any good solution?

Just do a loading, or when you let PHP output the HTML, the data will also be output to the page variables. In this way, Ajax loading will be omitted for the homepage

Front-end:
When using react, do you need to use its family bucket? What kind of webpack packaging? If it’s because of pictures, see if it can be lazy loading

Backend:

Without front-end, use chrome app postman to test whether simple ajax loading takes a lot of time. If so, then you need to look at the ping value of the server and whether there is anything that can be optimized in the database SQL statement and design

Between front-end and back-end:

Solved using Relay and GraphQL. This workload is relatively large. Facebook’s open source projects are used by themselves

The laziest method:

Add a splash screen (similar to the transition picture with the logo in the center when you just open the mobile app), or a prompt for data loading (loading...)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!