PHP with Post Method-1
Send request to the server by post method and reterive response

In this section we are sending request to the server by post method then getting data. in this section we create three page

2. Javascript
3. PHP

About Set Request Method

Set Request method is use to send value to the server by POST method of HTML form tag.

Code'POST', 'value.php', true);
XMLHttpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XMLHttpRequestObject.send("mytext=" + document.getElementById("mytext").value);

when send value to the server by html post method then this is necessary to use
Content-type- application/x-www-form-urlencoded

HTML page

<title>How to Submit Value through Ajax</title>
<script language="javascript" src="ajax.js"></script>
<form action="javascript:sendvalue(document.getElementById('frm'));" name="frm" id="frm">
Enter Text<input id="fname" type="text"/><br>
<input type="submit" name="button" value="Show Text">
<div name="txt" id="txt"></div>

Javascript page save as (ajax.js)

function sendvalue(obj)

var XMLHttpRequestObject=false;
XMLHttpRequestObject=new XMLHttpRequest();
else if(window.ActiveXObject)
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");

if (XMLHttpRequestObject.readyState==4 && XMLHttpRequestObject.status==200)
result = XMLHttpRequestObject.responseText;
document.getElementById('txt').innerHTML = result;
}'POST', 'value.php', true);
XMLHttpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XMLHttpRequestObject.send("fname=" + document.getElementById("fname").value);


PHP page save as (value.php)

echo $_POST['fname'];

Note: This page work behind the scenes.