What is the difference between form form and ajax submission?

青灯夜游
Release: 2022-01-13 18:00:33
Original
5877 people have browsed it

Difference: 1. Ajax submission is performed asynchronously, the web page does not need to be refreshed, but from form submission needs to be refreshed; 2. Ajax must be implemented with js, but the Form form is not required; 3. Ajax requires the use of a program To perform data processing on it, Form form submission is automatically completed according to the form structure and does not require code intervention.

What is the difference between form form and ajax submission?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

The difference between form submission and ajax submission

1. Usage scenarios:

Safety The properties are the same, and they are all sent using the http protocol. Security is related to the business processing of submitted files (format detection, anti-injection) and has nothing to do with the submission method.

Generally, a form is used to submit a login. Clicking submit triggers a submit event, which generally causes the page to jump. The control of page jumps and other behaviors is often in the backend, and the backend controls the page jumps and data transfer. ; But sometimes you don’t want the page to jump, or you want to put control on the front end and use js to operate the page jump or data change. Generally, ajax is used for such asynchronous operations.

But Ajax will have a hidden problem, that is, the browser does not save passwords, which is not in line with user habits. The ideal way: create a hidden iframe, point the target of the form tag to the iframe, and then detect the status of the iframe.

2. Comparison:

(1) Ajax is performed asynchronously when submitting, requesting, and receiving. The web page does not need to be refreshed. Only the part of the page is refreshed. It does not affect the content of other parts of the page.

Form submission is to create a new page. Even if it is submitted to its own page, it needs to be refreshed. In order to maintain the status change of the form by the page user, more parameters must be passed between the controller and the template. Maintain page status.

(2) When ajax is submitted, a new request is created in the background.

Form abandons this page and then requests again.

(3) Ajax must be implemented with js, which causes debugging troubles and browser compatibility issues. Moreover, browsers that do not enable js cannot complete the operation.

The Form form comes with the browser. You can submit the form regardless of whether js is enabled or not.

(4) When ajax submits, requests, and receives, the entire process requires the use of programs to process data.

Form form submission is automatically completed according to the form structure and does not require code intervention. Submit with submit.

3. Other aspects:

Regarding the verification of input content, ajax can use the program to judge the element content after getting it; there is verification in the attributes of the form form Fields are encapsulated in easyui, jeecg, etc. Users only need to add regular expression verification rules.

[Related tutorial recommendations: AJAX video tutorial]

The above is the detailed content of What is the difference between form form and ajax submission?. For more information, please follow other related articles on the PHP Chinese website!

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