[Proto-Scripty] using Ajax.Responders with multiple ajax requests
Hi everyone, hoping for a gentle ride: I mostly program actionscript rather than javascript, so although the syntax is similar i get a little stuck now and then. I'm using the global ajax.responders method to start an animation whenever an ajax request is made, and stop the animation upon completion of the request. however it does not work with synchronous requests. The onSuccess method of my ajax requests work as they should, however the timer continues to animate. It's as if the ajax.responders onComplete method isn't called. any idea what i'm doing wrong? thx kenneth Ajax.Responders.register({ onCreate: function(){ ajaxPageTimer = new __ajaxTimer('ajaxPageTimerBox',100); ajaxPageTimer.startAnimation(); }, onComplete: function(){ ajaxPageTimer.stopAnimation(); } }); var mainPages = Array(); var myRequests = new Object; function loadPages(pageSource, page){ var url; var i = 1; //loadPage(); function loadPage() { url = incfiles/main + i + .php; myRequests[i] = new Ajax.Request(url, { onSuccess: function(transport){ mainPages[i] = url; pasteMainContent.defer(transport.responseText, i); i++; if (imenu.num+1) loadPage(); //so this is faux asyncronous } }); } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: using Ajax.Responders with multiple ajax requests
Thank you for your help crowder. When i said It's as if the ajax.responders onComplete method isn't called. I meant that i really thought that it wasn't - i.e. just a turn of phrase. you're right the commented out loadPage request was only commented out because it wasn't working. I've changed the code as you suggested and it works fine now. I didn't realise all that stuff about writing over the original object and losing the reference. Anyway, it's sorted now, thanks for the direction kenneth ajaxPageTimer = new __ajaxTimer('ajaxPageTimerBox',100); Ajax.Responders.register({ onCreate: function(){ if (!ajaxPageTimer.animating) ajaxPageTimer.startAnimation(); }, onComplete: function(){ ajaxPageTimer.stopAnimation(); } }); var mainPages = Array(); var myRequests = new Object; function loadPages(pageSource, page){ var url; var i = 1; loadPage(); function loadPage() { url = incfiles/main + i + .php; myRequests[i] = new Ajax.Request(url, { onSuccess: function(transport){ mainPages[i] = url; pasteMainContent.defer(transport.responseText, i); i++; if (imenu.num+1) loadPage(); //so this is faux asyncronous } }); } } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---