Hi, I have read a number of the post in this group that suggest others are having probs too with this and tried (I think) all of the suggestions offered but still have a problem. The following code .. function actionMailbox(id, status, numberMailboxes) { lastMailboxId = id; var pars = "?action=actionMailbox&mailboxId=" + id + "&mailboxStatus=" + status; new Ajax.Updater( ''messageBox'', ''/anonymail/messageManager.do'' , { method: ''get'', parameters: pars, onComplete: function () { updateMailboxImage();} } ); } function updateMailboxImage() { var pars = "?action=updateImage&mailboxId=" + lastMailboxId; new Ajax.Updater( ''mailbox_'' + lastMailboxId, ''/anonymail/messageManager.do'' , { method: ''get'', parameters: pars } ); } works for the first function, but the onComplete function call doesn''t consistently work. The first call does some server side saving to db etc. (I have a number of functions that do other stuff), but then I want an image to change according to the state of a particular object that has just been altered in the first call. Obviously the second function therefore needs to be called when the first one has ''done its stuff'' and the object is in a new state. However, the second function doesn''t always get fired at the completion of the first one - it appears sometimes to get fired just before the end and therefore when it looks at the latest state of the object to then get the correct image to reflect the state, it hasn''t been fully saved to the db and the old state is retrieved resulting in the wrong image being shown. I can see that the second function is called before the end of the first when I look at the request in firebug (firefox extension). Can anyone suggest anything else I could try?? Thanks Conrad --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Oct-02 15:20 UTC
Re: Prototype onComplete callback not working consistently
Add an onException responder to see if that is causing a problem ... Ajax.Responders.register({onException:function(o_Requester, o_Exception, o_JSON){console.info(o_Requester, o_Exception, o_JSON);}}); Put that at the top of your script and then run it all again. Anything going wrong within the Ajax calls should be reported to firebug''s console. On 02/10/2007, cc_humbry <conrad.crampton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > I have read a number of the post in this group that suggest others are > having probs too with this and tried (I think) all of the suggestions > offered but still have a problem. > > The following code .. > > function actionMailbox(id, status, numberMailboxes) { > lastMailboxId = id; > var pars = "?action=actionMailbox&mailboxId=" + id + > "&mailboxStatus=" + status; > new Ajax.Updater( > ''messageBox'', > ''/anonymail/messageManager.do'' , > { > method: ''get'', > parameters: pars, > onComplete: function () { updateMailboxImage();} > } > ); > } > > function updateMailboxImage() { > var pars = "?action=updateImage&mailboxId=" + lastMailboxId; > new Ajax.Updater( > ''mailbox_'' + lastMailboxId, > ''/anonymail/messageManager.do'' , > { > method: ''get'', > parameters: pars > } > ); > } > > works for the first function, but the onComplete function call doesn''t > consistently work. The first call does some server side saving to db > etc. (I have a number of functions that do other stuff), but then I > want an image to change according to the state of a particular object > that has just been altered in the first call. Obviously the second > function therefore needs to be called when the first one has ''done its > stuff'' and the object is in a new state. However, the second function > doesn''t always get fired at the completion of the first one - it > appears sometimes to get fired just before the end and therefore when > it looks at the latest state of the object to then get the correct > image to reflect the state, it hasn''t been fully saved to the db and > the old state is retrieved resulting in the wrong image being shown. I > can see that the second function is called before the end of the first > when I look at the request in firebug (firefox extension). > > Can anyone suggest anything else I could try?? > > Thanks > Conrad > > > > >-- ----- 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 -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Oct-02 15:25 UTC
Re: Prototype onComplete callback not working consistently
On 02/10/2007, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Add an onException responder to see if that is causing a problem ... > > Ajax.Responders.register({onException:function(o_Requester, > o_Exception, o_JSON){console.info(o_Requester, o_Exception, > o_JSON);}}); > > Put that at the top of your script and then run it all again. Anything > going wrong within the Ajax calls should be reported to firebug''s > console. > > > > On 02/10/2007, cc_humbry <conrad.crampton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > I have read a number of the post in this group that suggest others are > > having probs too with this and tried (I think) all of the suggestions > > offered but still have a problem. > > > > The following code .. > > > > function actionMailbox(id, status, numberMailboxes) { > > lastMailboxId = id; > > var pars = "?action=actionMailbox&mailboxId=" + id + > > "&mailboxStatus=" + status; > > new Ajax.Updater( > > ''messageBox'', > > ''/anonymail/messageManager.do'' , > > { > > method: ''get'', > > parameters: pars, > > onComplete: function () { updateMailboxImage();} > > } > > ); > > } > > > > function updateMailboxImage() { > > var pars = "?action=updateImage&mailboxId=" + lastMailboxId; > > new Ajax.Updater( > > ''mailbox_'' + lastMailboxId, > > ''/anonymail/messageManager.do'' , > > { > > method: ''get'', > > parameters: pars > > } > > ); > > } > > > > works for the first function, but the onComplete function call doesn''t > > consistently work. The first call does some server side saving to db > > etc. (I have a number of functions that do other stuff), but then I > > want an image to change according to the state of a particular object > > that has just been altered in the first call. Obviously the second > > function therefore needs to be called when the first one has ''done its > > stuff'' and the object is in a new state. However, the second function > > doesn''t always get fired at the completion of the first one - it > > appears sometimes to get fired just before the end and therefore when > > it looks at the latest state of the object to then get the correct > > image to reflect the state, it hasn''t been fully saved to the db and > > the old state is retrieved resulting in the wrong image being shown. I > > can see that the second function is called before the end of the first > > when I look at the request in firebug (firefox extension). > > > > Can anyone suggest anything else I could try?? > > > > Thanks > > ConradHere is my AJAX.onException responder for all my code ... Ajax.Responders.register({ onException: function(o_Requester, o_Exception, o_JSON){ if (!isNull(o_AjaxReport)) { o_AjaxReport.update( ''<span class="MErrors_SPAN">'' + ''Error : '' + o_Exception.message + ''<br />'' + ((typeof o_Exception.fileName != ''undefined'') ? ''File : '' + o_Exception.fileName + ''<br />'' : '''') + ((typeof o_Exception.lineNumber != ''undefined'') ? ''Line : '' + o_Exception.lineNumber + ''<br />'' : '''') + ''</span><br />'' + o_Requester.transport.responseText + ''<br />'' ); o_AjaxReport.className = ''MAction_Failure_TH'' ); } }); I have a global <div id="ajaxReport" /> which I grab using o_AjaxReport = $(''ajaxReport''); Now ALL ajax exceptions are reported on screen (Ok, I''ve cut the above code RIGHT down to allow it to be easier to read). -- ----- 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 -~----------~----~----~----~------~----~------~--~---
Tobie Langel
2007-Oct-02 17:02 UTC
Re: Prototype onComplete callback not working consistently
Get firebug! On Oct 2, 5:25 pm, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 02/10/2007, Richard Quadling <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > Add an onException responder to see if that is causing a problem ... > > > Ajax.Responders.register({onException:function(o_Requester, > > o_Exception, o_JSON){console.info(o_Requester, o_Exception, > > o_JSON);}}); > > > Put that at the top of your script and then run it all again. Anything > > going wrong within the Ajax calls should be reported to firebug''s > > console. > > > On 02/10/2007, cc_humbry <conrad.cramp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > > I have read a number of the post in this group that suggest others are > > > having probs too with this and tried (I think) all of the suggestions > > > offered but still have a problem. > > > > The following code .. > > > > function actionMailbox(id, status, numberMailboxes) { > > > lastMailboxId = id; > > > var pars = "?action=actionMailbox&mailboxId=" + id + > > > "&mailboxStatus=" + status; > > > new Ajax.Updater( > > > ''messageBox'', > > > ''/anonymail/messageManager.do'' , > > > { > > > method: ''get'', > > > parameters: pars, > > > onComplete: function () { updateMailboxImage();} > > > } > > > ); > > > } > > > > function updateMailboxImage() { > > > var pars = "?action=updateImage&mailboxId=" + lastMailboxId; > > > new Ajax.Updater( > > > ''mailbox_'' + lastMailboxId, > > > ''/anonymail/messageManager.do'' , > > > { > > > method: ''get'', > > > parameters: pars > > > } > > > ); > > > } > > > > works for the first function, but the onComplete function call doesn''t > > > consistently work. The first call does some server side saving to db > > > etc. (I have a number of functions that do other stuff), but then I > > > want an image to change according to the state of a particular object > > > that has just been altered in the first call. Obviously the second > > > function therefore needs to be called when the first one has ''done its > > > stuff'' and the object is in a new state. However, the second function > > > doesn''t always get fired at the completion of the first one - it > > > appears sometimes to get fired just before the end and therefore when > > > it looks at the latest state of the object to then get the correct > > > image to reflect the state, it hasn''t been fully saved to the db and > > > the old state is retrieved resulting in the wrong image being shown. I > > > can see that the second function is called before the end of the first > > > when I look at the request in firebug (firefox extension). > > > > Can anyone suggest anything else I could try?? > > > > Thanks > > > Conrad > > Here is my AJAX.onException responder for all my code ... > > Ajax.Responders.register({ > onException: function(o_Requester, o_Exception, o_JSON){ > if (!isNull(o_AjaxReport)) { > o_AjaxReport.update( > ''<span class="MErrors_SPAN">'' + > ''Error : '' + o_Exception.message + ''<br />'' + > ((typeof o_Exception.fileName != ''undefined'') ? ''File : '' + > o_Exception.fileName + ''<br />'' : '''') + > ((typeof o_Exception.lineNumber != ''undefined'') ? ''Line : '' + > o_Exception.lineNumber + ''<br />'' : '''') + > ''</span><br />'' + > o_Requester.transport.responseText + ''<br />'' > ); > o_AjaxReport.className = ''MAction_Failure_TH'' > ); > } > > }); > > I have a global <div id="ajaxReport" /> which I grab using > o_AjaxReport = $(''ajaxReport''); > > Now ALL ajax exceptions are reported on screen (Ok, I''ve cut the above > code RIGHT down to allow it to be easier to read). > > -- > ----- > 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 -~----------~----~----~----~------~----~------~--~---
Brian Williams
2007-Oct-02 18:51 UTC
Re: Prototype onComplete callback not working consistently
or if you insist on doing all of your designing for IE whatever get Fiddler http://www.fiddlertool.com/fiddler/ and IEDevToolbar - both free downloads. but i recommend firebug for AJAX debugging and IEDevToolbar for debugging CSS in IE On 10/2/07, Tobie Langel <tobie.langel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Get firebug! > > > > On Oct 2, 5:25 pm, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > On 02/10/2007, Richard Quadling <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > > > > > Add an onException responder to see if that is causing a problem ... > > > > > Ajax.Responders.register({onException:function(o_Requester, > > > o_Exception, o_JSON){console.info(o_Requester, o_Exception, > > > o_JSON);}}); > > > > > Put that at the top of your script and then run it all again. Anything > > > going wrong within the Ajax calls should be reported to firebug''s > > > console. > > > > > On 02/10/2007, cc_humbry <conrad.cramp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hi, > > > > I have read a number of the post in this group that suggest others > are > > > > having probs too with this and tried (I think) all of the > suggestions > > > > offered but still have a problem. > > > > > > The following code .. > > > > > > function actionMailbox(id, status, numberMailboxes) { > > > > lastMailboxId = id; > > > > var pars = "?action=actionMailbox&mailboxId=" + id + > > > > "&mailboxStatus=" + status; > > > > new Ajax.Updater( > > > > ''messageBox'', > > > > ''/anonymail/messageManager.do'' , > > > > { > > > > method: ''get'', > > > > parameters: pars, > > > > onComplete: function () { > updateMailboxImage();} > > > > } > > > > ); > > > > } > > > > > > function updateMailboxImage() { > > > > var pars = "?action=updateImage&mailboxId=" + lastMailboxId; > > > > new Ajax.Updater( > > > > ''mailbox_'' + lastMailboxId, > > > > ''/anonymail/messageManager.do'' , > > > > { > > > > method: ''get'', > > > > parameters: pars > > > > } > > > > ); > > > > } > > > > > > works for the first function, but the onComplete function call > doesn''t > > > > consistently work. The first call does some server side saving to db > > > > etc. (I have a number of functions that do other stuff), but then I > > > > want an image to change according to the state of a particular > object > > > > that has just been altered in the first call. Obviously the second > > > > function therefore needs to be called when the first one has ''done > its > > > > stuff'' and the object is in a new state. However, the second > function > > > > doesn''t always get fired at the completion of the first one - it > > > > appears sometimes to get fired just before the end and therefore > when > > > > it looks at the latest state of the object to then get the correct > > > > image to reflect the state, it hasn''t been fully saved to the db and > > > > the old state is retrieved resulting in the wrong image being shown. > I > > > > can see that the second function is called before the end of the > first > > > > when I look at the request in firebug (firefox extension). > > > > > > Can anyone suggest anything else I could try?? > > > > > > Thanks > > > > Conrad > > > > Here is my AJAX.onException responder for all my code ... > > > > Ajax.Responders.register({ > > onException: function(o_Requester, o_Exception, o_JSON){ > > if (!isNull(o_AjaxReport)) { > > o_AjaxReport.update( > > ''<span class="MErrors_SPAN">'' + > > ''Error : '' + o_Exception.message + ''<br > />'' + > > ((typeof o_Exception.fileName !> ''undefined'') ? ''File : '' + > > o_Exception.fileName + ''<br />'' : '''') + > > ((typeof o_Exception.lineNumber !> ''undefined'') ? ''Line : '' + > > o_Exception.lineNumber + ''<br />'' : '''') + > > ''</span><br />'' + > > o_Requester.transport.responseText + > ''<br />'' > > ); > > o_AjaxReport.className = ''MAction_Failure_TH'' > > ); > > } > > > > }); > > > > I have a global <div id="ajaxReport" /> which I grab using > > o_AjaxReport = $(''ajaxReport''); > > > > Now ALL ajax exceptions are reported on screen (Ok, I''ve cut the above > > code RIGHT down to allow it to be easier to read). > > > > -- > > ----- > > 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 -~----------~----~----~----~------~----~------~--~---
cc_humbry
2007-Oct-03 13:00 UTC
Re: Prototype onComplete callback not working consistently
already using firebug. the suggestions offered around using an ''onException'' handler are welcome thanks. However, have done this and still no further forward as no exceptions are being thrown. I am at the point of believing this is an issue with the way the database is being updated with hibernate/ struts etc. and that the db isn''t actually getting the data committed even when the ajax request has (as far as it is concerned) completed. I don''t understand how this can be, but the http requests are showing as being consecutive (in firebug for the main part), the logs files of my application are showing hibernate logging later than the log messages that are produced by the second ajax request. Complete mystery for me. I have got around this issue for the shortterm by returning the javascript function call along with the reponse html from the first ajax call, that calls the second ajax request, but having this as setTimout(''updateMailboxImage'', 1000) so giving the db time to update. Obviously not the way I would like this to be done but getting too frustrated with trying to get this work with the ''onComplete'' callback function I anyone can add anything further to this issue please feel free to comment - I will give anything a go ;-) Conrad On Oct 2, 7:51 pm, "Brian Williams" <brianw1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> or if you insist on doing all of your designing for IE whatever get Fiddlerhttp://www.fiddlertool.com/fiddler/and IEDevToolbar - both free downloads. > > but i recommend firebug for AJAX debugging and IEDevToolbar for debugging > CSS in IE > > On 10/2/07, Tobie Langel <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Get firebug! > > > On Oct 2, 5:25 pm, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > wrote: > > > On 02/10/2007, Richard Quadling <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > Add an onException responder to see if that is causing a problem ... > > > > > Ajax.Responders.register({onException:function(o_Requester, > > > > o_Exception, o_JSON){console.info(o_Requester, o_Exception, > > > > o_JSON);}}); > > > > > Put that at the top of your script and then run it all again. Anything > > > > going wrong within the Ajax calls should be reported to firebug''s > > > > console. > > > > > On 02/10/2007, cc_humbry <conrad.cramp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hi, > > > > > I have read a number of the post in this group that suggest others > > are > > > > > having probs too with this and tried (I think) all of the > > suggestions > > > > > offered but still have a problem. > > > > > > The following code .. > > > > > > function actionMailbox(id, status, numberMailboxes) { > > > > > lastMailboxId = id; > > > > > var pars = "?action=actionMailbox&mailboxId=" + id + > > > > > "&mailboxStatus=" + status; > > > > > new Ajax.Updater( > > > > > ''messageBox'', > > > > > ''/anonymail/messageManager.do'' , > > > > > { > > > > > method: ''get'', > > > > > parameters: pars, > > > > > onComplete: function () { > > updateMailboxImage();} > > > > > } > > > > > ); > > > > > } > > > > > > function updateMailboxImage() { > > > > > var pars = "?action=updateImage&mailboxId=" + lastMailboxId; > > > > > new Ajax.Updater( > > > > > ''mailbox_'' + lastMailboxId, > > > > > ''/anonymail/messageManager.do'' , > > > > > { > > > > > method: ''get'', > > > > > parameters: pars > > > > > } > > > > > ); > > > > > } > > > > > > works for the first function, but the onComplete function call > > doesn''t > > > > > consistently work. The first call does some server side saving to db > > > > > etc. (I have a number of functions that do other stuff), but then I > > > > > want an image to change according to the state of a particular > > object > > > > > that has just been altered in the first call. Obviously the second > > > > > function therefore needs to be called when the first one has ''done > > its > > > > > stuff'' and the object is in a new state. However, the second > > function > > > > > doesn''t always get fired at the completion of the first one - it > > > > > appears sometimes to get fired just before the end and therefore > > when > > > > > it looks at the latest state of the object to then get the correct > > > > > image to reflect the state, it hasn''t been fully saved to the db and > > > > > the old state is retrieved resulting in the wrong image being shown. > > I > > > > > can see that the second function is called before the end of the > > first > > > > > when I look at the request in firebug (firefox extension). > > > > > > Can anyone suggest anything else I could try?? > > > > > > Thanks > > > > > Conrad > > > > Here is my AJAX.onException responder for all my code ... > > > > Ajax.Responders.register({ > > > onException: function(o_Requester, o_Exception, o_JSON){ > > > if (!isNull(o_AjaxReport)) { > > > o_AjaxReport.update( > > > ''<span class="MErrors_SPAN">'' + > > > ''Error : '' + o_Exception.message + ''<br > > />'' + > > > ((typeof o_Exception.fileName !> > ''undefined'') ? ''File : '' + > > > o_Exception.fileName + ''<br />'' : '''') + > > > ((typeof o_Exception.lineNumber !> > ''undefined'') ? ''Line : '' + > > > o_Exception.lineNumber + ''<br />'' : '''') + > > > ''</span><br />'' + > > > o_Requester.transport.responseText + > > ''<br />'' > > > ); > > > o_AjaxReport.className = ''MAction_Failure_TH'' > > > ); > > > } > > > > }); > > > > I have a global <div id="ajaxReport" /> which I grab using > > > o_AjaxReport = $(''ajaxReport''); > > > > Now ALL ajax exceptions are reported on screen (Ok, I''ve cut the above > > > code RIGHT down to allow it to be easier to read). > > > > -- > > > ----- > > > 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 -~----------~----~----~----~------~----~------~--~---