XMLHttpRequest
object:
open ( <method>, <url>, <is async>)
send (<request_data>)
- How are these different and why do we need both to implement ajax?
- Also, can the
<request_data>
be passed through both the methods ?
XMLHttpRequest
object:
open ( <method>, <url>, <is async>)
send (<request_data>)
- How are these different and why do we need both to implement ajax?
- Also, can the
<request_data>
be passed through both the methods ?
-
3
Your question has a misconception. The argument to
send()
isn't the URL, it's the data to send in aPOST
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
3 Answers
Reset to default 4open() 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.