Search This Blog

Wednesday, August 11, 2010

AJAX Skeleton Examples

You can use the following AJAX for basic purpose



function getContentList(url,divId) {

var xmlHttpRequest;


if (window.XMLHttpRequest) {
xmlHttpRequest = new XMLHttpRequest();
} else if(window.ActiveXObject) {
xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlHttpRequest.open("POST", url, true);

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

xmlHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

xmlHttpRequest.send(null);

}

No comments:

Post a Comment