K
kasper48
Hello,
I am using the following script to load content into a DIV tag on my
webpage when an onclick calls the 'loadXMLDiv1' function...I am trying
to add a section variable in the 'loadXMLDiv1' function ('divname')
that will specify which Div ID to load the content into.
This line:
getObject(divname).innerHTML = req.responseText;
is where the content gets loaded, but no matter what I try, I cant
pass the info in 'divname' from the 'loadXMLDiv1' function to the
'processChange' function... I want to get info that is in 'divname' to
tell the script where to load the content from the request.
The code is below, of course, I am a newbie with Javascript and have
tried my best to solve this one myself.
Any help would be greatly appreciated.
Cheers,
Greg
---- code below!
<!--
var req = null;
function loadXMLDiv1(url, divname) {
// Internet Explorer
try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e) {
try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(oc) { req = null; }
}
// Mozailla/Safari
if (req == null && typeof XMLHttpRequest != "undefined") {
req = new XMLHttpRequest();
}
// Call the processChange() function when the page has loaded
if (req != null) {
var div;
req.onreadystatechange = processChange;
req.open("GET", url, true);
req.send(null);
}
}
function processChange(evt) {
// The page has loaded and the HTTP status code is 200 OK
if (req.readyState == 4) {
if (req.status == 200) {
// Write the contents of this URL to the div layer
getObject(divname).innerHTML = req.responseText;
}
}
}
I am using the following script to load content into a DIV tag on my
webpage when an onclick calls the 'loadXMLDiv1' function...I am trying
to add a section variable in the 'loadXMLDiv1' function ('divname')
that will specify which Div ID to load the content into.
This line:
getObject(divname).innerHTML = req.responseText;
is where the content gets loaded, but no matter what I try, I cant
pass the info in 'divname' from the 'loadXMLDiv1' function to the
'processChange' function... I want to get info that is in 'divname' to
tell the script where to load the content from the request.
The code is below, of course, I am a newbie with Javascript and have
tried my best to solve this one myself.
Any help would be greatly appreciated.
Cheers,
Greg
---- code below!
<!--
var req = null;
function loadXMLDiv1(url, divname) {
// Internet Explorer
try { req = new ActiveXObject("Msxml2.XMLHTTP"); }
catch(e) {
try { req = new ActiveXObject("Microsoft.XMLHTTP"); }
catch(oc) { req = null; }
}
// Mozailla/Safari
if (req == null && typeof XMLHttpRequest != "undefined") {
req = new XMLHttpRequest();
}
// Call the processChange() function when the page has loaded
if (req != null) {
var div;
req.onreadystatechange = processChange;
req.open("GET", url, true);
req.send(null);
}
}
function processChange(evt) {
// The page has loaded and the HTTP status code is 200 OK
if (req.readyState == 4) {
if (req.status == 200) {
// Write the contents of this URL to the div layer
getObject(divname).innerHTML = req.responseText;
}
}
}