Table of Contents
Reply content:
Simply put, separate the front and back ends through data interfaces (such as ajax requests).
Negative case
Positive Cases
Design ideas:
Advantages of front-end and back-end separation
Home Backend Development PHP Tutorial javascript - I beg the master: How to best cooperate with the front and back ends

javascript - I beg the master: How to best cooperate with the front and back ends

Aug 04, 2016 am 09:20 AM
html java javascript node.js php

Produce dynamic php and jsp pages with data, and the front-end and back-end packaging and publishing are completely independent.
The advantage of this is the performance of the front-end layer. The data is completely controlled by the front-end.
Any problems can be solved independently by the front-end and packaged and released separately.

The packaging and release of front-end and back-end are completely independent. The meaning and understanding of this game

Reply content:

Produce dynamic php and jsp pages with data, and the front-end and back-end packaging and publishing are completely independent.
The advantage of this is the performance of the front-end layer. The data is completely controlled by the front-end.
Any problems can be solved independently by the front-end and packaged and released separately.

The packaging and release of front-end and back-end are completely independent. The meaning and understanding of this game

The front-end and back-end are separated, the front-end is engineered, and all interactions between the front-end and the back-end are through the API. You may think that this is not good for SEO, but now with nodejs, page rendering can be left to the front-end. In fact, this is also a trend. The end-end should care about system availability, performance and other issues, and should not focus on page issues. This part should be left to the front-end.

This blog should be able to help you develop ideas for separate front-end and back-end web development by livoras

First, determine the communication protocol and communication parameters.
Front-end independent jobs can use tools such as mock to simulate background data transmission.
Back-end design uses data models to complete business and generate interfaces.
Personally, I think it is similar to separating the view business such as the template engine in PHP from the project to form an independent front-end version?

The front and back ends interact through API. It doesn't matter whether you use the web front-end or the ios and Android client.

The backend should try to use the same API to meet the needs of multiple front-end pages or even different front-ends. This is the best. The front end needs to know what data is returned by the back end and how it should be rendered according to the design diagram.

A while ago I wrote an article on the steps to develop non-native APP using ionic and cordova on the front end and CoreThink on the back end http://www.oschina.net/question/2598464_2151690?fromerr=mCRfZH2m You can take a look

Simply put, separate the front and back ends through data interfaces (such as ajax requests).

Negative case

I took over a semi-formed web project last year: it was developed in the backend PHP language. I wouldn’t know it without looking at the code. When I looked at the code, I fainted. The code is basically as follows:

    <?php
    ...
    echo val;
    ?>
    <html>
    <?php echo ...?>
    </html>
Copy after login

The entire php file contains the flavor of html. I won’t go into details, you should understand. Except for the css file, I threw up. Deeply hurt the heart of OCD. Language can still be used in this way. Once again I felt like I had chosen the wrong path. I thought the world of code could be more organized, but it seems I was wrong.
After thinking about it, I realized that if it was developed in this way, it would be hard enough for one person to cover both the front and back ends. However, this hybrid development model does have an advantage, which is low cost and high efficiency. There are a lot of shortcomings, and expansion and later maintenance are problematic.

Positive Cases

Last year, I also took over a web project. The main requirement: display the content in the background database table. To put it bluntly, it is to imitate the web control of MySQL. But it's simple. But there are requirements: Modeling, that is, by modifying a small number of parameters in the background, you can control the number of tables displayed on the front end, and even the column names of the tables. In other words, all information about the table on the front end is provided by the back end. The front-end only needs to make display adjustments to the interface based on the back-end data.

Design ideas:

1. The style of the table and the dynamic operation of the mouse on the table are used as part of the front-end module;
2. The table name information and list information of the table are returned to json by the ajax request server, and the json can be dynamically created locally by slightly verifying the json locally. Table;
3. Data acquisition also applies to ajax acquisition. Then populate the local table;
4. All local additions, deletions and modifications to data are uploaded to the server through ajax;

The only running-in point is the ajax interface. During development, due to the slowness of the backend, some interfaces passed fake data directly to the frontend through echo.

Advantages of front-end and back-end separation

Through the development of the data interface model, the front-end and back-end are completely separated, and because this project is a model-based design, the code reuse is very high.
Moreover, if a problem occurs, by detecting the data in the data interface, it is easy to know whether it is a front-end problem or a back-end problem. It is very easy to maintain and even carry out in-depth secondary development.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1272
29
C# Tutorial
1251
24
HTML vs. CSS and JavaScript: Comparing Web Technologies HTML vs. CSS and JavaScript: Comparing Web Technologies Apr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

HTML as a Markup Language: Its Function and Purpose HTML as a Markup Language: Its Function and Purpose Apr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

Composer: Aiding PHP Development Through AI Composer: Aiding PHP Development Through AI Apr 29, 2025 am 12:27 AM

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

What does 'platform independence' mean in the context of Java? What does 'platform independence' mean in the context of Java? Apr 23, 2025 am 12:05 AM

Java's platform independence means that the code written can run on any platform with JVM installed without modification. 1) Java source code is compiled into bytecode, 2) Bytecode is interpreted and executed by the JVM, 3) The JVM provides memory management and garbage collection functions to ensure that the program runs on different operating systems.

What is the significance of the session_start() function? What is the significance of the session_start() function? May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

H5: Key Improvements in HTML5 H5: Key Improvements in HTML5 Apr 28, 2025 am 12:26 AM

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

See all articles