Hi...
I am working in AJAX and use GET and POST method. How can we define HTTP GET and HTTP POST method in ajax and define syntax for any ajax call?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Dec 8, 2011, 12:48 PM
GET and POST
GET is simpler and faster than POST, and can be used in most cases.
However, always use POST requests when:
* A cached file is not an option (update a file or database on the server)
* Sending a large amount of data to the server (POST has no size limitations)
* Sending user input (which can contain unknown characters), POST is more robust and secure than GET
GET Requests
xmlhttp.open("GET","demo_get.asp",true);
xmlhttp.send();
If you want to send information with the GET method, add the information to the URL:
Example
xmlhttp.open("GET","demo_get2.asp?fname=Henry&lname=Ford",true);
xmlhttp.send();
POST Requests
Example
xmlhttp.open("POST","demo_post.asp",true);
xmlhttp.send();
To POST data like an HTML form, add an HTTP header with setRequestHeader(). Specify the data you want to send in the send() method:
Example
xmlhttp.open("POST","ajax_test.asp",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("fname=Henry&lname=Ford");
Please refer the below links
http://www.openjs.com/articles/ajax_xmlhttp_using_post.php
http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
Thanks