Discussion:
Ajax.Request - onSuccess called before onComplete
pennig
2007-09-18 17:03:00 UTC
Permalink
I've noticed that inside Ajax.Request's respondToReadyState function,
when the readyState is "Complete", the onSuccess callback is called
before the onComplete callback.

This behavior affects how Ajax.Updater is run, and I was curious if
the execution sequence was a mindful decision.

The scenario I have is I am using Ajax.Updater to fill an element with
content, and in my onSuccess callback, I am running code that depends
on new content being in my element. Ajax.Updater does its HTML
insertion on the onComplete callback. What this means is that when
onSuccess runs, it doesn't know about the new content because the new
content hasn't actually been updated.

Would it be at all possible to switch around the order of execution in
respondToReadyState so that onSuccess (and hence, onFailure) to be
called after onComplete?

I know, at first glance, onComplete seems to be the most logical
choice of what to call _last_. I am just imagining that a good number
of people who use onSuccess with Ajax.Updater would expect to have the
new content be accessible at that time.


--~--~---------~--~----~------------~-------~--~----~
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-/***@public.gmane.org
To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Matt Foster
2007-09-18 18:00:31 UTC
Permalink
Use Ajax.Request, insert the responseText into said HTML object, then
perform collection routine to said object.
Post by pennig
I've noticed that inside Ajax.Request's respondToReadyState function,
when the readyState is "Complete", the onSuccess callback is called
before the onComplete callback.
This behavior affects how Ajax.Updater is run, and I was curious if
the execution sequence was a mindful decision.
The scenario I have is I am using Ajax.Updater to fill an element with
content, and in my onSuccess callback, I am running code that depends
on new content being in my element. Ajax.Updater does its HTML
insertion on the onComplete callback. What this means is that when
onSuccess runs, it doesn't know about the new content because the new
content hasn't actually been updated.
Would it be at all possible to switch around the order of execution in
respondToReadyState so that onSuccess (and hence, onFailure) to be
called after onComplete?
I know, at first glance, onComplete seems to be the most logical
choice of what to call _last_. I am just imagining that a good number
of people who use onSuccess with Ajax.Updater would expect to have the
new content be accessible at that time.
--~--~---------~--~----~------------~-------~--~----~
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-/***@public.gmane.org
To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
pennig
2007-09-18 18:22:32 UTC
Permalink
Post by Matt Foster
Use Ajax.Request, insert the responseText into said HTML object, then
perform collection routine to said object.
Thank you Matt. I ended up doing that as a workaround right after
writing the first post. Yes. It's a fast and trivial option.

However, I was interested in discussing the underlying reason why I
had to do that in the first place. What I was trying to accomplish
doesn't seem like an edge case, but if it is, perhaps it should be
documented. I was particularly confused when two callbacks (onSuccess
and onComplete) which, conceptually, should happen at the same time,
reflected different states.


--~--~---------~--~----~------------~-------~--~----~
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-/***@public.gmane.org
To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...