SEE IT YOURSELF
*************************************************************************************
function ahah(url, target, funcname) {
function ahahDone() {
if(req.readyState == 4){
if(req.status == 200){
if(!(target == undefined)){
document.getElementById(target).innerHTML = req.responseText;
}
if(!(funcname == undefined)){
eval(funcname+"(req.responseText);");
}
}else{
if(!(target == undefined)){
document.getElementById(target).innerHTML = "ahah
error:\n"+req.statusText;
}
if(!(funcname == undefined)){
eval(funcname+"(req.responseText);");
}
}
}
}
if(!(target == undefined)){
document.getElementById(target).innerHTML = 'caricamento dati in
corso...';
}
if(window.XMLHttpRequest){
var req = new XMLHttpRequest();
}else if(window.ActiveXObject) {
var req = new ActiveXObject("Microsoft.XMLHTTP");
}
if(req){
req.onreadystatechange = function() {
ahahDone();
};
req.open("GET", url, true);
req.send("");
}
}
*************************************************************************************
USAGE
ahah("processer.php?var1=xxx&var2=yyy","mydiv");
or:
ahah("processer.php?var1=xxx&var2=yyy", undefined, "myfunction");
This second one is very useful if you need to pass the processed data
into a function:
function myfunction(my_processer_response){
....
}
Hope this helps anyone, bye!
Sax
ManaLab.com
thx for your contribute. It is possible to do also using SetTimeout
like this function
http://groups.google.com/group/XMLHttpRequest/browse_thread/thread/07eb7f167dcb5006/#
cheers ;)
Daniele
In one case you're forced to send first one request then the second,
in the other case all ahah request is apart from others (and easy to
use): when ready it will be served!
Another interesting functionality is the possibility to send the result
to a function rather than on a div.. the code could be better but it
works fine
Please visit our testing area:
http://www.manalab.com/lab/ahah/
Sx
AS
Thanks again!