function createXMLHttpRequest(){
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function createQueryString()
{
var firstName = document.getElementById("firstName").value;
var middleName = document.getElementById("middleName").value;
var birthDay = document.getElementById("birthDay").value;
var queryString = "firstName="+ firstName +"&middleName="+middleName+"&birthDay="+birthDay;
return queryString;
}
function doRequestUsingGet(){
createXMLHttpRequest();
var queryString = "WebForm2.ASPx?";
queryString = queryString + createQueryString() + "&timeStamp="+new Date().getTime();
XMLHttp.onreadystatechange = handleStateChange;
XMLHttp.open("GET",queryString,true);
XMLHttp.send(null);
}
function doRequestUsingPost(){
createXMLHttpRequest();
var url = "WebForm2.ASPx?timeStamp="+new Date().getTime();
var queryString = createQueryString();
XMLHttp.open("POST",url,true);
XMLHttp.onreadystatechange = handleStateChange;
XMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
XMLHttp.send(queryString);
}
function handleStateChange(){
if(XMLHttp.readyState == 4)
{
if(XMLHttp.status == 200)
{
parseResults();
}
}
}
function parseResults(){
var responseDiv = document.getElementById("serverResponse");
var testStr = XMLHttp.responseText;
document.getElementById("firstName").value = testStr;
}