Java Reference
In-Depth Information
◦ GET requests to retrieve resources
◦ POST requests, usually used to create a resource but can
actually perform any task
◦ PUT requests to upsert , which means insert a resource or
update it entirely
◦ PATCH requests to make partial updates to a resource
◦ DELETE requests to delete a resources
By default, a link in a web page will make a GET request and a
form will send a POST request. When sending an Ajax request,
the HTTP verb needs to be given explicitly as an argument to the
open() method.
• The second parameter is the URL address to which we are sending the request.
• The last parameter is whether or not the request is to be sent asynchronously. This
is almost exclusively set to true , as setting it to false can cause numerous prob-
lems:"GET", "path/to/resource", true);
Warning: Avoid Synchronous Requests
It is possible to make a synchronous request using Ajax, but it should
be avoided. If the response takes a long time, everything running in that
browser tab will be blocked. This means that the browser menus, rendering,
and downloads will all be stopped until the Ajax response is received―not
a nice user experience!
Sending the Request
The last step is to actually send the request using the send() method:
Search WWH ::

Custom Search