czwartek, sierpnia 10, 2006

HOWTO:AJAX workaround - ITtoolbox Wiki

HOWTO:AJAX workaround - ITtoolbox Wiki:
"function processStateChange(){
statusDiv = document.getElementById('status');
if (req.readyState == 0){ statusDiv.innerHTML = 'UNINITIALIZED'; }
if (req.readyState == 1){ statusDiv.innerHTML = 'LOADING'; }
if (req.readyState == 2){ statusDiv.innerHTML = 'LOADED'; }
if (req.readyState == 3){ statusDiv.innerHTML = 'INTERACTIVE'; }
if (req.readyState == 4){ statusDiv.innerHTML = ' '; }
if (req.readyState == 4){
if (req.status == 200){
response = req.responseText;
destinationDiv = document.getElementById(dest);
destinationDiv.innerHTML = response;
} else {
statusDiv.innerHTML = 'Error: Status '+req.status;
}
}
}
function loadHTML(url, destination){
dest = destination;
if (window.XMLHttpRequest){
req = new XMLHttpRequest();
req.onreadystatechange = processStateChange;
req.open('GET', url, true);
req.send(null);
} else if (window.ActiveXObject) {
req = new ActiveXObject('Microsoft.XMLHTTP');
if (req) {
req.onreadystatechange = processStateChange;
req.open('GET', url, true);
req.send();
}
}
} ... "

Brak komentarzy: