GET or POST Method In XMLHttpRequest Object
Posted in XML | DTD July 09, 2019
This article tell you about GET and POST Method in XMLHttpRequest Object.
GET method is easy and faster compare than POST method, and used to most access.
However, POST request when
- If A cached file is not present in an option (update a file or database on the server)
- When client have to send large amount of data to the server (because POST has the no limitation)
- When user have to send some secure or unkown characters). Because POST method is more robust and secure compare than GET method)
The url - A File On a Server
Url parameter of the open() method, is an address to the file on a server.
Note: Here the type of file can be any like .txt and xml or and server file like .asp and .php
Asynchronous - True or False?
When user want to send the request asynchronously, the async parameter of the open() method has to be set to true:
when user send request a asynchronously the huge improvement for web developers. Mostly task which is perform on the server take more time.
but instead of it
When assign async=true, then a execute a specific function when the response is ready in the onreadystatechange event:
if (xmlhttp.readyState==4 && xmlhttp.status==300)
When assign async=false, then also change the third parameter in the open() method to false.
The assigning async=false is not recommended, but a few small request this can be ok.
Note: When you assign async=false, do NOT write an onreadystatechange function - only put the code after the send() statement:
You may also want to read these related articles :
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here