Home > Uncategorized > Ajax using post

Ajax using post

August 2nd, 2008

Here is a sample code which uses POST method in XMLHTTP request.

var url="ajaxpage.php";
var parms="name=bobby"; //Parameters
xmlHttp.open("POST", url, true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", parms.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.onreadystatechange = function() {
             //On ready state execute the below code
	     if(http.readyState == 4 || http.status == 200) {
		alert(xmlHttp.responseText);
	}
}
xmlHttp.send(parms);

[Post to Twitter]   [Post to Plurk]   [Post to Digg]   [Post to ping.fm]

Related posts

Shoban Uncategorized

  1. September 21st, 2008 at 00:55 | #1

    I have written a small post on Ajax using post. Take a look.

  1. No trackbacks yet.