Aug 2 2008

Ajax using post

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

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);

Add to Del.cio.us RSS Feed Add to Technorati Favorites Stumble It! Digg It!
    www.sajithmr.com

TAGS: ,

1 Comments on this post

Trackbacks

  1. Binny V A said:
    I have written a small post on Ajax using post. Take a look.
    September 21st, 2008 at 12:55 am

LEAVE A COMMENT

Subscribe Form

Subscribe to Blog