Sunday, March 21, 2010

Post to a page

var HPtoken = null;
var xmlHttpReq = false;
var self = this;

if (window.XMLHttpRequest)
{
self.xmlHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', 'http://somewebsite.com', true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function()
{
if (self.xmlHttpReq.readyState == 4)
{
alert(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(null);

No comments:

Post a Comment