Is it synchronous or asynchronous using HTTP?

Source: Internet
Author: User

Synchronous vs. asynchronous

synchronization: submit request, wait for server processing, processing completed returns this period the client browser cannot do anything
Asynchronous: requests are processed through event triggering server processing (which is still something the browser can do)

Get and Postget

the most common HTTP request, the normal Internet browsing page is get. The get mode parameter request is immediately followed by the URL, starting with a question mark. (JS is obtained with Window.location.search). Parameters can be encoded with encodeuricomponent, using the following methods:

Var

The URL supports only 2048 characters, so it is common to use post for AJAX requests.

POST

It is used to submit data to the server.
The values in the form form need to be taken out first to be converted to strings, concatenated with the & symbol (same as get arguments), commit data 2GB; using Ajax.setrequestheader (' Content-type ', ' application/ X-www-form-urlencoded '), which handles the submitted string, Ajax.send (strings), which represents what needs to be committed in the form, such as a=1&b=2 a string like this.

Execution mode synchronous execution mode

The so-called synchronous execution mode, refers to the statement in synchronous execution mode, will always maintain control of the program flow, until the end of the program. In the case of a query operation, the application on the client side waits for the server to return the query result to the client after the instruction of the query operation is issued to the server before proceeding to the next step.
It is well known that it is time-consuming for an application to remove all records from a large table, and if the application is using single-threaded (thread) synchronous execution, a deletion is likely to delay the completion of other important work. If the application waits for a remote task, a remote server failure or network failure or some unpredictable situation can cause the application to wait indefinitely, which is the biggest flaw in synchronous execution.
But synchronous execution patterns can simplify the complexity of programming. Programmers can improve development efficiency by not having to learn more about the use of the more complex ODBC 2.0 APIs, but simply by using the ODBC synchronous execution pattern or by using data controls and database object variables, but the program runs faster than the asynchronous execution pattern.

Asynchronous execution mode

Asynchronous execution mode refers to the statement in asynchronous execution mode, the order in which statements are executed is not necessarily the same as the order in which the statements are executed. For example, a query operation, when an application on the client sends a command to the server for a query operation, executes the next statement of the query statement instruction immediately, without waiting for the server to return the query results to the client side. Asynchronous execution allows applications to get rid of individual tasks, increasing flexibility and application execution efficiency. But there are also problems with asynchronous execution patterns, such as the increased complexity of programming, especially when writing interoperability (interoperable)-demanding programs.

Selecting and setting the execution mode choose synchronous or asynchronous mode in application development, which is a more complex level. Synchronous execution mode is a good choice when querying or modifying a database is relatively simple, and it can return result data in seconds or less. In addition, you do not have to use asynchronous execution mode at all when you cannot continue execution until the application obtains the result set. In the case of complex queries, especially the update or delete operations of complex multi-row databases, it can take a long time to complete, using asynchronous execution mode, allowing the user to manipulate other parts of the program at the same time.
For the general programmer, if he does not understand the synchronous execution mode and asynchronous execution mode, he will often make an action statement (query or read a record, etc.) to the server, the execution result returned by the reference server, or the next operation of the result, it is very dangerous. Because, in asynchronous execution mode, subsequent statements on the client are executed after the action statement is issued, but for various reasons, the server may not be able to execute the Operation statement and return the result to the client before the subsequent statement executes. Therefore, the subsequent statement in reference to the execution results of the previous action statement, often because the execution result does not exist and reference the wrong value, resulting in a system error or deadlock, so in the actual application should be carefully selected execution mode according to the specific situation.

Is it synchronous or asynchronous using HTTP?

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.