Richard Quadling
2007-Apr-23 12:15 UTC
How do I get a chance to handle the response to an Ajax.PeriodicalUpdater?
Hi. Take this piece of working code ... obj_Ajax_FPN_Progress = new Ajax.PeriodicalUpdater ( ''FPN_Progress'', ''/FPN_Progress.php?FPN='' + s_FPN, { method : ''get'', frequency : 1, decay : 1.5 }); Currently this is started by the user filling in a text box and clicking a button. The progress shows how far through the server side processing things have gone. All fine. The response from the server is straight HTML at the moment (an image for a spinner and some text). This all works great. The main process (also started via an AJAX call) results are handled via ... var a_Results = eval(''('' + unescape(transport.responseText) + '')''); and then the a_Results array is processed. Everything is fine - all works. But. The process of handling the FPN can take a long time. The main process is generating results as it goes and holds them until the end. I can make the results available in real time (i.e. to the PeriodicalUpdater), but I don''t want to generate the HTML server side (as this actual server code is used for other things). If I want to deal with the results in realtime, I seem to be able to use the onSuccess() method and set the container to a hidden span. Is there anything I''ve missed? Is there a more appropriate way to do this? obj_AjaxFaxCheckProgress = new Ajax.PeriodicalUpdater ( ''hidden'', ''/faxReferenceDecoderProgress.php?FaxReferenceCode='' + s_FaxReferenceCode, { method : ''get'', frequency : 1, decay : 1.5, onSuccess : function(transport) { var a_Results = eval(''('' + unescape(transport.responseText) + '')''); if (transport.responseText.indexOf(''PROGRESS'') != -1) { $(''FPN_Progress'').update(a_Results.PROGRESS); console.dir(a_Results); WriteGuesses(a_Results, true); } } }); Have I missed something obvious? Regards, Richard Quadling. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---