Javascript XMLHttpRequest. Send () method

Source: Internet
Author: User

Post below


XMLHttpRequest. Send ()

Send an HTTP request

Syntax

Send (Body)

If you call
The HTTP method specified by open () is post or put. The body parameter specifies the Request body as a string or document object.

If the request body is not required, this parameter is null.

This parameter is unavailable for any other method and should be null (some implementations cannot omit this parameter ).

Description

This method causes an HTTP request to be sent. If open () is not called before, or, more specifically, if readystate is not 1, send () throws an exception. Otherwise, it sends an HTTP request consisting of the following parts:

* The HTTP method, URL, and authentication qualifications (if any) specified when you call open ).
* The Request Header specified when setRequestHeader () was called (if any ).
* The Body parameter passed to this method.

Once the request is published, send () sets readystate to 2 and triggers the onreadystatechange event handle.

If the previously called open () parameter async is false, this method will be blocked and will not be returned until the readystate is 4 and the server's response is fully received.

Otherwise, if the async parameter is true or this parameter is omitted, send () returns immediately, and as described later, the server response will be processed in a background thread.

If the server response carries an HTTP redirection, The send () method or background thread automatically follows the redirection. When all HTTP Response Headers have been received, the send () or background thread sets readystate to 3 and triggers the onreadystatechange event handle.

If the response is long, the send () or background thread may trigger the onreadystatechange event handle in status 3: this can be used as a download progress indicator. Finally, when the response is complete, the send () or background thread sets readystate to 4 and triggers the event handle for the last time.

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.