Create an Account
username: password:
 
  MemeStreams Logo

How to do AHAH without a freakin framework

search

Lost
Picture of Lost
My Blog
My Profile
My Audience
My Sources
Send Me a Message

sponsored links

Lost's topics
Arts
Business
Games
Health and Wellness
Home and Garden
Miscellaneous
Current Events
Recreation
Local Information
Science
Society
Sports
Technology

support us

Get MemeStreams Stuff!


 
How to do AHAH without a freakin framework
Topic: Technology 12:54 am EDT, Apr 13, 2008

// Returns a new XMLHttpRequest for IE and others
function createXMLHttpRequest()
{
if (window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
}

// Insert content from a url to a div AJAX style using a GET
function doAJAXGet(divId, url)
{
if(document.getElementById(divId))
{
// Until the div's content loads, assign a 'loading' image.
document.getElementById(divId).innerHTML = "

";

var xmlHttp = createXMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState == 4)
{
if(xmlHttp.status == 200)
{
document.getElementById(divId).innerHTML = xmlHttp.responseText;
}
}
};

xmlHttp.open("GET", url, true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.send(null);
}
}

// Insert content from a url to a div AJAX style using a POST
function doAJAXPost(divId, url, args)
{
if(document.getElementById(divId))
{
// Until the grid loads, assign a 'loading' image.
document.getElementById(divId).innerHTML = "

";

var grid_xmlHttp = createXMLHttpRequest();
grid_xmlHttp.onreadystatechange = function() {
if(grid_xmlHttp.readyState == 4)
{
if(grid_xmlHttp.status == 200)
{
document.getElementById(divId).innerHTML = xmlHttp.responseText;
}
}
};
grid_xmlHttp.open("POST", url, true);
grid_xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
grid_xmlHttp.send(args);
}
}

How to do AHAH without a freakin framework



 
 
Powered By Industrial Memetics
RSS2.0