ok there you go.
this is a cross browser xmlHTTPRequest
here is an asyncronous call (script is not waiting for answer)
this is a cross browser xmlHTTPRequest
Code:
function getHTTPobj() {
try {
return new XMLHttpRequest();
} catch (e) {
try {
return new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
return new ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {
return false;
}
}
}
}
Code:
var URL="http:/something.somehwere.org/data.xml";
var ajax = getHTTPobj();
// Method,URL,Async
ajax.open('GET',URL,true);
ajax.setRequestHeader("Pragma", "no-cache");
ajax.setRequestHeader("Cache-Control", "must-revalidate");
ajax.setRequestHeader("If-Modified-since", document.lastModified);
// this is the function that is called when the xml data is downloaded complete
ajax.onreadystatechange=function() {
// readyState 4 = complete
if(ajax.readyState==4) {
// HTTP Status 200 OK
if(ajax.status == 200) {
var xml = ajax.responseXML
// check if returning XML is an Archiv list
if(xml.getElementsByTagName('LIST')[0] != undefined) {
// grab an HTML Element (<div id='yourTextBoxID' />
document.getElementById('yourTextBoxID').innerText = xml.xml;
} else {
// do some error checking
}
} else {
// do some error checking
}


Kommentar