Request methods include GET and POST: GET, which are the most common HTTP requests. The GET request directly follows the URL and starts with a question mark. (Window. location. search is used in JS ). The parameters can be encoded using encodeURIComponent. Usage:
Var EnParam = encodeURIComponent (param );
The URL can only be about 2 k in length, that is, 2048 characters. When AJAX requests are made using GET, the cached page may not appear correctly. Generally, the random parameter value is added. ajax. send (null ).
POST
It is used to submit data to the server.
You need to extract and convert the values in the form into strings and connect them with the & Symbol (same as the GET parameter). Submit 2 GB of data volume. Use ajax. setRequestHeader ('content-type', 'application/x-www-form-urlencoded') to process the submitted string. ajax. send (strings). This strings indicates the content to be submitted in form, for example, a = 1 & B = 2.
Synchronous and asynchronous:
In the ajax. open method, 3rd parameters are set to synchronous or asynchronous. Js class libraries such as prototype are generally asynchronous by default, that is, set to true. First, in the case of synchronization, js will wait for the request to return and get the status. Onreadystatechange event handler is not required. While asynchronous processing requires onreadystatechange event processing, and the value is 4, and then the following content is processed correctly.
(Note: ajax in the text indicates the XMLHTTP request object .)