hi there I am working on a webpage that needs to retrieve some data off of another web page. below is my code that i am using. My question is why is the varaible that stores the html code from the other site getting the value of null. I was hoping that it would give the me html code of the other page.
please help???
var req;
var cU = {
init: function() {
if (!document.getElementById) return;
if (!Sarissa) return;
//if (!cU.name) return;
loadXMLDoc(' },
addEvent: function(elm, evType, fn, useCapture) {
// cross-browser event handling for IE5+, NS6 and Mozilla
// By Scott Andrew
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
} else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
} else {
elm['on' + evType] = fn;
}
}
}
cU.addEvent(window, 'load', cU.init, false);
function loadXMLDoc(url) {
// branch for IE/Windows ActiveX version
// if (window.ActiveXObject) {
// // branch for native XMLHttpRequest object
// if (window.XMLHttpRequest) {
// req = new XMLHttpRequest();
//
// req.open("GET", url, true);
// req.send(null);
// req.onreadystatechange = processReqChange;
// branch for IE/Windows ActiveX version
//} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.open("GET", url, true);
req.send();
req.onreadystatechange = processReqChange;
}
// }
// }
}
function getTables(dom) {
document.getElementById('texthtml').appendChild(document.createTextNode("HELP HELP!!!"));
//var alternative = .getElementsByTagName('body')[0];
document.getElementById('texthtml').appendChild(req.responseText);
}
function processReqChange() {
// only if req shows "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
getTables(req.responseXML);
} else {
alert("There was a problem retrieving the XML data:\n" +
req.statusText);
}
}
}
please help???
var req;
var cU = {
init: function() {
if (!document.getElementById) return;
if (!Sarissa) return;
//if (!cU.name) return;
loadXMLDoc(' },
addEvent: function(elm, evType, fn, useCapture) {
// cross-browser event handling for IE5+, NS6 and Mozilla
// By Scott Andrew
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
} else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
} else {
elm['on' + evType] = fn;
}
}
}
cU.addEvent(window, 'load', cU.init, false);
function loadXMLDoc(url) {
// branch for IE/Windows ActiveX version
// if (window.ActiveXObject) {
// // branch for native XMLHttpRequest object
// if (window.XMLHttpRequest) {
// req = new XMLHttpRequest();
//
// req.open("GET", url, true);
// req.send(null);
// req.onreadystatechange = processReqChange;
// branch for IE/Windows ActiveX version
//} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.open("GET", url, true);
req.send();
req.onreadystatechange = processReqChange;
}
// }
// }
}
function getTables(dom) {
document.getElementById('texthtml').appendChild(document.createTextNode("HELP HELP!!!"));
//var alternative = .getElementsByTagName('body')[0];
document.getElementById('texthtml').appendChild(req.responseText);
}
function processReqChange() {
// only if req shows "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
getTables(req.responseXML);
} else {
alert("There was a problem retrieving the XML data:\n" +
req.statusText);
}
}
}