Hello,
I built a tree and results are loading in a frame with :
tree.attachEvent(“onClick”,function(id){
document.getElementById(‘fra’).src=“organism.php?id=”+id;});
It’s working good.
Now i try to load results in a div on the same page with an “include” and i can’t find the solution.
Can you guide me ?
Thank you.
Hello Darya,
I found this solution, and it works :
tree.attachEvent("onClick",function(id){
function getXMLHttpRequest() {
var xhr = null;
if (window.XMLHttpRequest || window.ActiveXObject) {
if (window.ActiveXObject) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
} else {
xhr = new XMLHttpRequest();
}
} else {
alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
return null;
}
return xhr;
}
function request(callback) {
var xhr = getXMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
callback(xhr.responseText);
}
}
xhr.open("GET", "organism.php?id="+id, true);
xhr.send(null);
}
function readData(sData) {
document.getElementById("my_div").innerHTML=sData;
}
request(readData);
});
Thank you for your help.
You are welcome!