function getNewHTTPObject()
{
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch (e)
{
xmlhttp = false;
}
}
return xmlhttp;
}
/*this function post successfully*/
function postForm(getposturl)
{
var xmlvalue=null;
var xmlpost = new getNewHTTPObject();
xmlpost.onreadystatechange=Gtpost;
xmlvalue="posttitle="+ posttitle.value +"&txtnewpost="+post1.value;
var tmppost = encodeURI(getposturl);
xmlpost.open('POST', tmppost, false);
xmlpost.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlpost.setRequestHeader("Content-length", xmlvalue.length);
xmlpost.setRequestHeader("Connection", "close");
xmlpost.send(xmlvalue);
return;
}
This blog provide knowledge of all type of query. I want to share my experience with all.
Showing posts with label XMLHttpRequest. Show all posts
Showing posts with label XMLHttpRequest. Show all posts
Thursday, 30 April 2009
Wednesday, 29 April 2009
XMLHttpRequest - GET Method
GET Method:
//object creation.
function getNewHTTPObject()
{
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch (e)
{
xmlhttp = false;
}
}
return xmlhttp;
}
function GetResponse()
{
var xmlHttp= new getNewHTTPObject();
xmlHttp.onreadystatechange = httpCallBack;
/*here httpCallBack is function, this function continues running till get final response.*/
xmlHttp.open('GET','http://www.google.co.in',true);
xmlHttp.Send(null);
}
function httpCallBack()
{
if (xmlHttp.readyState == 4)
{
var xmlDoc = null;
if (xmlHttp.status==200)
{
if (xmlHttp.responseText)
{
var myresp= xmlHttp.responseText;
//myresp geting response from URL.
}
}
else
{
alert('no response or error');
}
}
}
//object creation.
function getNewHTTPObject()
{
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch (e)
{
xmlhttp = false;
}
}
return xmlhttp;
}
function GetResponse()
{
var xmlHttp= new getNewHTTPObject();
xmlHttp.onreadystatechange = httpCallBack;
/*here httpCallBack is function, this function continues running till get final response.*/
xmlHttp.open('GET','http://www.google.co.in',true);
xmlHttp.Send(null);
}
function httpCallBack()
{
if (xmlHttp.readyState == 4)
{
var xmlDoc = null;
if (xmlHttp.status==200)
{
if (xmlHttp.responseText)
{
var myresp= xmlHttp.responseText;
//myresp geting response from URL.
}
}
else
{
alert('no response or error');
}
}
}
Subscribe to:
Posts (Atom)