Do you mean to use
function callProcBasketEmail(e) {
var pars = Form.serialize('email-form');
var myAjax = new Ajax.Updater('email-response',
'procBasketEmail.php', {
method: 'post',
parameters: pars,
onComplete: function(response)
{
Event.observe('password-form', 'submit',
callProcBasketPassword);
}
});
Event.stop(e);
}
rather than testing for onSuccess?
On Aug 5, 11:07 pm, DJ Mangus <[email protected]> wrote:
> OK, just checked the source. onComplete is where ajax.updater
> actually updates the node. onSuccess is called before that.
> Workaround is to either a.) use defer like you did, or b.) use
> Ajax.request and update it yourself onSuccess, then do your
> Event.observe.
>
> Plusses of option b is that it won't try and update anything upon a
> failed ajax request.
>
> On Wed, Aug 5, 2009 at 3:03 PM, Ash<[email protected]> wrote:
>
> > I wonder why in this case, that onSuccess is executed before the DOM
> > node has been created.
>
> > Using a hack is okay to get me up and running but I would like to know
> > how to use ajax methods correctly
>
> > On Aug 5, 10:48 pm, DJ Mangus <[email protected]> wrote:
> >> yes but onSuccess shouldn't be called until after the ajax.updater is
> >> completed. Therefore the DOM node should be available at that point.
>
> >> On Wed, Aug 5, 2009 at 2:40 PM, Alex
>
> >> McAuley<[email protected]> wrote:
>
> >> > Ajax is Asyncronous so it gets executed along with other script ...
> >> > ergo its not serial like php and other stuff your prolly used to...
>
> >> > you can make a request synconous (script waits for the ajax request to
> >> > finish before continuing but its not recommended
>
> >> > Alex Mcauley
> >> >http://www.thevacancymarket.com
> >> > ----- Original Message -----
> >> > From: "Ash" <[email protected]>
> >> > To: "Prototype & script.aculo.us"
> >> > <[email protected]>
> >> > Sent: Wednesday, August 05, 2009 10:37 PM
> >> > Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop
> >> > in
> >> > AJAX
>
> >> > That seems to be working!
>
> >> > Is Event.observe.defer a standard method, or is it only to be used in
> >> > certain cases?
>
> >> > I'm happy that it's working but I would really like to learn the
> >> > basics properly.
>
> >> > Thanks anyway for getting me up and running!
> >> > Ashley
>
> >> > On Aug 5, 10:32 pm, DJ Mangus <[email protected]> wrote:
> >> >> good question. You might change Event.observe( . . . etc to
> >> >> Event.observe.defer( . . . and see if that fixes it. Odd that the
> >> >> node isn't available in the DOM at onSuccess but that might work
> >> >> around it while I research.
>
> >> >> On Wed, Aug 5, 2009 at 2:22 PM, Ash<[email protected]> wrote:
>
> >> >> > yes, when I check the HTML tab, the form with the id=password-form has
> >> >> > not been created within the email-response div, even though I have
> >> >> > waited to check for it with the onSuccess line
>
> >> >> > EG
>
> >> >> > function callProcBasketEmail(e) {
> >> >> > var pars = Form.serialize('email-form');
> >> >> > var myAjax = new Ajax.Updater('email-response',
> >> >> > 'procBasketEmail.php', {
> >> >> > method: 'post',
> >> >> > parameters: pars,
> >> >> > onSuccess: function(response)
> >> >> > {
> >> >> > Event.observe('password-form', 'submit',
> >> >> > callProcBasketPassword);
> >> >> > }
> >> >> > });
> >> >> > Event.stop(e);
> >> >> > }
>
> >> >> > Once I jump past the error, the email-response div gets populated with
> >> >> > the form i'm trying to observe, so the question is, why is the
> >> >> > onSuccess running before the DOM has been updated?
>
> >> >> > On Aug 5, 10:17 pm, DJ Mangus <[email protected]> wrote:
> >> >> >> actually just checked firebug, best place would be html tab. DOM tab
> >> >> >> lists the entire DOM which would be very hard to go through.
>
> >> >> >> On Wed, Aug 5, 2009 at 2:12 PM, Ash<[email protected]>
> >> >> >> wrote:
>
> >> >> >> > Sorry, i'm quite new to this, should I be looking for the form
> >> >> >> > id=password-form element in the DOM, not sure where to look for it
> >> >> >> > in
> >> >> >> > the DOM tab of firebug?
>
> >> >> >> > Is this correct?
>
> >> >> >> > On Aug 5, 10:06 pm, DJ Mangus <[email protected]> wrote:
> >> >> >> >> <nods> when Firebug breaks on the error, check the DOM tab to see
> >> >> >> >> the
> >> >> >> >> state at that particular moment.
>
> >> >> >> >> On Wed, Aug 5, 2009 at 2:05 PM, Alex
>
> >> >> >> >> McAuley<[email protected]> wrote:
>
> >> >> >> >> > Seems the element does not exist...
>
> >> >> >> >> > Does it exist in the DOM ?
>
> >> >> >> >> > Alex Mcauley
> >> >> >> >> >http://www.thevacancymarket.com
> >> >> >> >> > ----- Original Message -----
> >> >> >> >> > From: "Ash" <[email protected]>
> >> >> >> >> > To: "Prototype & script.aculo.us"
> >> >> >> >> > <[email protected]>
> >> >> >> >> > Sent: Wednesday, August 05, 2009 10:04 PM
> >> >> >> >> > Subject: [Proto-Scripty] Re: Beginners question, trouble with
> >> >> >> >> > Event.stop in
> >> >> >> >> > AJAX
>
> >> >> >> >> > When I set firebug to break on all errors...
>
> >> >> >> >> > Submit the first form and I get (from prototype.js)
>
> >> >> >> >> > function getEventID(element) {
> >> >> >> >> > element is null3936 if (element._prototypeEventID) return
> >> >> >> >> > element._prototypeEventID[0]; (element is null error)
>
> >> >> >> >> > if I step past it and submit the second form I get the same
> >> >> >> >> > error
> >> >> >> >> > again
>
> >> >> >> >> > Unfortunately I don't know why both errors are caused, can you
> >> >> >> >> > help
> >> >> >> >> > please?
>
> >> >> >> >> > On Aug 5, 9:40 pm, DJ Mangus <[email protected]> wrote:
> >> >> >> >> >> Are you getting any Javascript errors? Note: firefox and
> >> >> >> >> >> firebug
> >> >> >> >> >> is
> >> >> >> >> >> your friend. Don't forget to break on all errors.
>
> >> >> >> >> >> On Wed, Aug 5, 2009 at 11:22 AM,
> >> >> >> >> >> Ash<[email protected]>
> >> >> >> >> >> wrote:
>
> >> >> >> >> >> > Hi, I wasn't sure whether you meant in the 1st or second
> >> >> >> >> >> > function, but
> >> >> >> >> >> > it doesn't make a difference in either.
>
> >> >> >> >> >> > I think it is the Event.observe('password-form', 'submit',
> >> >> >> >> >> > callProcBasketPassword); which is not working properly,
> >> >> >> >> >> > although I
> >> >> >> >> >> > don't know how to debug it
>
> >> >> >> >> >> > On Aug 5, 6:48 pm, DJ Mangus <[email protected]> wrote:
> >> >> >> >> >> >> Try adding e.preventDefault(); instead of Event.stop(e) and
> >> >> >> >> >> >> let me
> >> >> >> >> >> >> know if that works?
>
> >> >> >> >> >> >> On Tue, Aug 4, 2009 at 4:55 PM,
> >> >> >> >> >> >> Ash<[email protected]> wrote:
> >> >> >> >> >> >> > function callProcBasketEmail(e) {
> >> >> >> >> >> >> > var pars = Form.serialize('email-form');
> >> >> >> >> >> >> > var myAjax = new Ajax.Updater('email-response',
> >> >> >> >> >> >> > 'procBasketEmail.php', {
> >> >> >> >> >> >> > method: 'post',
> >> >> >> >> >> >> > parameters: pars,
> >> >> >> >> >> >> > onSuccess: function(response)
> >> >> >> >> >> >> > {
> >> >> >> >> >> >> > Event.observe('password-form', 'submit',
> >> >> >> >> >> >> > callProcBasketPassword);
> >> >> >> >> >> >> > }
> >> >> >> >> >> >> > });
> >> >> >> >> >> >> > Event.stop(e);
> >> >> >> >> >> >> > }
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---