Hi all, I did a search on onComplete here and on Google but didn''t find the answer to what is probably a simple enough problem to resolve for someone who uses javascript/prototype more than me. I am creating a shopping cart and I''m using form.request() when adding a product to the cart which is working really well including the addition of various options for each product. However once I have added each item I want to update the Cart Overview from "You have no items in your cart" to "You have XX items totalling £XX.XX in your cart". I am using the following which is doing as it should but a bit too fast: onClick=\"$(''shopCartAdd'').request({ onComplete: updater({container: ''shopCartOverview'', action: ''shopCartUpdate''}) });\" but the onComplete is firing before my php script has updated the cart table so it simply refreshes the overview content rather than updating it with the new product count and total. I have tried using onSuccess as well but I am assuming AJAX deems getting a connection to the script as a success so ploughs on at lightening speed. Anyway of stopping the onComplete/onSuccess from firing until my php script has done it''s thing with the form data? Paul. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This doesn''t work: you''re calling updater(...) first and then assigning the result to your onComplete handler. onClick = $(''shopCartAdd'').request({ onComplete: function(xhr) { updater({container: ''shopCartOverview'', action: ''shopCartUpdate''}); } }); -Fred On Mon, Jul 7, 2008 at 1:46 PM, WebbedIT <paul-BKqkkOijtfm9FHfhHBbuYA@public.gmane.org> wrote:> > Hi all, > > onClick=\"$(''shopCartAdd'').request({ > onComplete: updater({container: ''shopCartOverview'', action: > ''shopCartUpdate''}) > });\" > > but the onComplete is firing before my php script has updated the cart > table so it simply refreshes the overview content rather than updating > it with the new product count and total.-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---