AJAX GET POST

AJAX GET

Example GET AJAX call.

xmlhttp.open("GET","info.txt",true); xmlhttp.send();

You can also send information to the server with the GET method

xmlhttp.open("GET","info.php?firstname=AXEL&lastname=WILSON",true); xmlhttp.send();

AJAX POST

Example GET AJAX call

xmlhttp.open("POST","info.txt",true);
xmlhttp.send();

To send information to the server with POST method

xmlhttp.open("POST","info.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send("firstname=AXEL&lastname=WILSON");

To add HTTP headers to the request is used:

setRequestHeader(header,value)

header: specifies the header name

value: specifies the header value