PDA

View Full Version : Loading HTML into two divs using AJAX/AHAH



DankaShine
11 Sep 2006, 12:01 PM
I'm using the following AHAH code in my site:


function ahah(url, target) {
document.getElementById(target).innerHTML = ' Fetching data...';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req != undefined) {
req.onreadystatechange = function() {ahahDone(url, target);};
req.open("GET", url, true);
req.send("");
}
}

function ahahDone(url, target) {
if (req.readyState == 4) { // only if req is "loaded"
if (req.status == 200) { // only if "OK"
document.getElementById(target).innerHTML = req.responseText;
} else {
document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
}
}
}

function load(name, div) {
ahah(name,div);
return false;
}

with the following link:

<a onclick="load('production.php','textArea');return false;" href="consulting.php">Overview</a>

Which works great. My question is, how do I modify the script/link reference to make it load TWO pages into TWO divs on the same page? The following types of link references do not work:



<a onclick="load('production.php','textArea','none.php','pulledContent');return false;" href="production.php">Overview</a></li>

<a onclick="load('production.php','textArea','none.php','pulledContent');return false;" href="production.php">Overview</a>

<a onclick="load('production.php','textArea');load('none.php','pulledContent');return false;" href="production.php">Overview</a>