multiple ahah

122 views
Skip to first unread message

sax'ntouebbe

unread,
Aug 28, 2006, 5:22:31 AM8/28/06
to XMLHttpRequest
Hi!
I was told that was impossible to send multiple ahah request, so i
began to study and did it.
Actually it was a question to set the variable as local!

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

daniele...@gmail.com

unread,
Aug 29, 2006, 1:47:57 AM8/29/06
to XMLHttpRequest
Hi Sax

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

sax'ntouebbe

unread,
Sep 1, 2006, 5:38:59 AM9/1/06
to XMLHttpRequest
I don't think its the same thing

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

thesmartass.info

unread,
Sep 10, 2006, 1:01:08 AM9/10/06
to XMLHttpRequest
Hey thanks, I haven't worked on this in awhile, but this looks like
something I would use.

ashore

unread,
Sep 29, 2006, 10:39:59 AM9/29/06
to XMLHttpRequest
Ummm, I dunno. Have you tried it with something less instantaneous
than echo rand(); , like a database hit?

AS

sax'ntouebbe

unread,
Sep 29, 2006, 10:58:12 AM9/29/06
to XMLHttpRequest
yes, i'm working on a website based on this feature, please download
the example and try yourself!
Sax

thesmartass.info

unread,
Oct 22, 2006, 3:00:12 PM10/22/06
to XMLHttpRequest
Genius, this works so much better than settimeout. I can finally
finish the design I had going that uses this feature heavily. Will
post example once site launched (site will also use thickbox, jquery,
and prototype (if i can work out conflicts between jquery/proto)

thesmartass.info

unread,
Oct 24, 2006, 11:04:20 AM10/24/06
to XMLHttpRequest
Ok, my website is now using this heavily: http://www.thesmartass.info
. I still have tons of features to add to the site, but it should act
as strong example of using this hack to load multiple ahah requests.

Thanks again!

Reply all
Reply to author
Forward
0 new messages