简体   繁体   中英

What is the difference between open( ) and send ( ) methods of XMLHttpRequest object?

XMLHttpRequest object:

open ( <method>, <url>, <is async>)
send (<request_data>)

  1. How are these different and why do we need both to implement ajax?
  2. Also, can the <request_data> be passed through both the methods ?

open() does not open the connection; it only configures the request, but the network activity only starts with the call of send ()

The HTTP and HTTPS requests of the XMLHttpRequest object must be initialized through the open method. This method must be invoked prior to the actual sending of a request to validate and resolve the request method, URL, and URI user information to be used for the request. This method does not assure that the URL exists or the user information is correct. This method can accept up to five parameters, but requires only two, to initialize a request.

1.open() 方法将打开特定的 url(用于在服务器上打开) 2.send() 方法向服务器发送 HTTP 请求并接收响应。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM