最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is the difference between open( ) and send ( ) methods of XMLHttpRequest object? - Stack Overflow

programmeradmin0浏览0评论

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 ?

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 ?
Share Improve this question edited Oct 16, 2017 at 0:50 Pacerier 89.8k111 gold badges384 silver badges644 bronze badges asked Mar 31, 2015 at 7:28 SatyendraSatyendra 1,7053 gold badges20 silver badges33 bronze badges 3
  • 3 Your question has a misconception. The argument to send() isn't the URL, it's the data to send in a POST request. – Barmar Commented Mar 31, 2015 at 7:30
  • 1 You are not right, send takes request data as a parameter: developer.mozilla/ru/docs/Web/API/XMLHttpRequest – Artyom Neustroev Commented Mar 31, 2015 at 7:30
  • 1 your questions are based on that misunderstanding. Now that it is fixed, they no longer make sense. Except the part about needing them both in quesiton 1. – Touffy Commented Apr 2, 2015 at 12:52
Add a ment  | 

3 Answers 3

Reset to default 4

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() method will open specific url ( for open on server) 2.send() method Sends an HTTP request to the server and receives a response.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论