[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-05 Thread Ash

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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-05 Thread Ash

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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-05 Thread Ash

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 d.man...@gmail.com 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

 McAuleywebmas...@thecarmarketplace.com wrote:

  Seems the element does not exist...

  Does it exist in the DOM ?

  Alex Mcauley
 http://www.thevacancymarket.com
  - Original Message -
  From: Ash ashley.kenner...@gmail.com
  To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
  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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-05 Thread Ash

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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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

  McAuleywebmas...@thecarmarketplace.com wrote:

   Seems the element does not exist...

   Does it exist in the DOM ?

   Alex Mcauley
  http://www.thevacancymarket.com
   - Original Message -
   From: Ash ashley.kenner...@gmail.com
   To: Prototype  script.aculo.us 
   prototype-scriptaculous@googlegroups.com
   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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 
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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-05 Thread Ash

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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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

   McAuleywebmas...@thecarmarketplace.com wrote:

Seems the element does not exist...

Does it exist in the DOM ?

Alex Mcauley
   http://www.thevacancymarket.com
- Original Message -
From: Ash ashley.kenner...@gmail.com
To: Prototype  script.aculo.us 
prototype-scriptaculous@googlegroups.com
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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 
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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 
 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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-05 Thread Ash

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 d.man...@gmail.com 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

 McAuleywebmas...@thecarmarketplace.com 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 ashley.kenner...@gmail.com
  To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
  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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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

McAuleywebmas...@thecarmarketplace.com wrote:

 Seems the element does not exist...

 Does it exist in the DOM ?

 Alex Mcauley
http://www.thevacancymarket.com
 - Original Message -
 From: Ash ashley.kenner...@gmail.com
 To: Prototype  script.aculo.us
 prototype-scriptaculous@googlegroups.com
 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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com
 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 d.man...@gmail.com 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,
  Ashashley.kenner...@gmail.com wrote:
   function callProcBasketEmail(e) {
   var pars = Form.serialize('email-form');
   var myAjax = new Ajax.Updater

[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-05 Thread Ash

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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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

  McAuleywebmas...@thecarmarketplace.com 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 ashley.kenner...@gmail.com
   To: Prototype  script.aculo.us 
   prototype-scriptaculous@googlegroups.com
   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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 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 d.man...@gmail.com 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, Ashashley.kenner...@gmail.com 
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 d.man...@gmail.com 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

 McAuleywebmas...@thecarmarketplace.com wrote:

  Seems the element does not exist...

  Does it exist in the DOM ?

  Alex Mcauley
 http://www.thevacancymarket.com
  - Original Message -
  From: Ash ashley.kenner...@gmail.com
  To: Prototype  script.aculo.us
  prototype-scriptaculous@googlegroups.com
  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

[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-04 Thread Ash

Hi TJ, thanks for the help, I understand the concept of onSuccess and
have updated my javascript. That function runs without an error, but
the observe line does not some to be working (the form keeps trying to
submit using the standard old fashioned method) I think I am missing
something else fundamental.

Here is the javascript:


// Attach handler to window load event
Event.observe(window, 'load', init, false);

function init(){
 Event.observe('email-form', 'submit', callProcBasketEmail);
}


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);
}



function callProcBasketPassword(e) {
 var pars = Form.serialize('password-form');
 alert(pars);
 var myAjax = new Ajax.Updater('password-response',
'procBasketPassword.php', {method: 'post', parameters: pars});
 Event.stop(e);
}





and here is the HTML once the first function callProcBasketEmail(e)
has run:



form id=email-form action=# method=post
input id=email class=texterwide type=text name=email/
input id=email-submit class=button type=submit value=Submit/
/form
div id=email-response
form id=password-form action=# method=post
input id=password class=texterwide type=text name=password/
input id=password-submit class=button type=submit
value=Submit/
/form
/div
div id=password-response name=password-response/



 Thanks again in advance! :)
Ashley

On Aug 3, 5:46 pm, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

  But this stops the whole function from working - where should the
  observe line be placed to ensure it will work properly?

 Right, because this new line:

  Event.observe('password-form', 'submit', callProcBasketPassword);

 ...will cause an error, because there is no element with the ID
 'password-form' yet.  Remember that Ajax calls are *asynchronous*
 (that's what the A in Ajax stands for).  You start the call at the
 point in your code where you create the Ajax.Updater object, but then
 your code continues immediately without waiting for the Ajax call to
 finish.  As DJ pointed out, that's what the onSuccess callback is for
 -- so you can execute code once the Ajx call has successfully
 completed.  So it would look something like this:

 http://pastie.org/569908

 In terms of getting you past these initial hurtles, some recommended
 reading:http://prototypejs.org/learn/introduction-to-ajaxhttp://proto-scripty.wikidot.com/prototype:how-to-bulletproof-ajax-re...http://prototypejs.org/api/ajax/requesthttp://prototypejs.org/api/ajax/updater

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available

 On Aug 3, 2:23 pm, Ash ashley.kenner...@gmail.com wrote:

  Thanks for the help, I just tried replacing Event.stop(e); with return
  false; in the function but it still submits the form.

  I would prefer to do it the new way anyway, if you would be able to
  help me...

  The first function is called from Event.observe('email-form',
  'submit', callProcBasketEmail); which is within a function that is
  called when the document loads.

  The question is, where to put the event observe to watch the second
  form.

  My first instinct would be to put it in the function which outputs the
  form EG

  function callProcBasketEmail(e) {
   var pars = Form.serialize('email-form');
   var myAjax = new Ajax.Updater('email-response',
  'procBasketEmail.php', {method: 'post', parameters: pars});
   Event.observe('password-form', 'submit', callProcBasketPassword);
   Event.stop(e);

  }

  (line added just after the ajax function has drawn 'password-form' to
  the screen)

  But this stops the whole function from working - where should the
  observe line be placed to ensure it will work properly?

  Thanks in advance, I think once I get over these initial few hurdles
  of getting to grips with good practices, I will be fine!

  Ashley

  Here is the javascript in full:

  // Attach handler to window load event
  Event.observe(window, 'load', init, false);

  function init(){
      Event.observe('email-form', 'submit', callProcBasketEmail);

  }

  function callProcBasketEmail(e) {
   var pars = Form.serialize('email-form');
   var myAjax = new Ajax.Updater('email-response',
  'procBasketEmail.php', {method: 'post', parameters: pars});
   Event.observe('password-form', 'submit', callProcBasketPassword);
   Event.stop(e);

  }

  function callProcBasketPassword(e) {
   var pars = Form.serialize('password-form');
   alert(pars);
   var myAjax = new Ajax.Updater('password-response',
  'procBasketPassword.php', {method: 'post', parameters: pars});
   Event.stop(e);

  }

  On Aug 2, 11:19 am, T.J. Crowder t...@crowdersoftware.com wrote:

   Hi Ashley,

   In the one that's not working

[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-03 Thread Ash

Thanks for the help, I just tried replacing Event.stop(e); with return
false; in the function but it still submits the form.

I would prefer to do it the new way anyway, if you would be able to
help me...

The first function is called from Event.observe('email-form',
'submit', callProcBasketEmail); which is within a function that is
called when the document loads.

The question is, where to put the event observe to watch the second
form.

My first instinct would be to put it in the function which outputs the
form EG


function callProcBasketEmail(e) {
 var pars = Form.serialize('email-form');
 var myAjax = new Ajax.Updater('email-response',
'procBasketEmail.php', {method: 'post', parameters: pars});
 Event.observe('password-form', 'submit', callProcBasketPassword);
 Event.stop(e);
}

(line added just after the ajax function has drawn 'password-form' to
the screen)

But this stops the whole function from working - where should the
observe line be placed to ensure it will work properly?

Thanks in advance, I think once I get over these initial few hurdles
of getting to grips with good practices, I will be fine!

Ashley


Here is the javascript in full:






// Attach handler to window load event
Event.observe(window, 'load', init, false);

function init(){
Event.observe('email-form', 'submit', callProcBasketEmail);
}

function callProcBasketEmail(e) {
 var pars = Form.serialize('email-form');
 var myAjax = new Ajax.Updater('email-response',
'procBasketEmail.php', {method: 'post', parameters: pars});
 Event.observe('password-form', 'submit', callProcBasketPassword);

 Event.stop(e);
}

function callProcBasketPassword(e) {
 var pars = Form.serialize('password-form');
 alert(pars);

 var myAjax = new Ajax.Updater('password-response',
'procBasketPassword.php', {method: 'post', parameters: pars});
 Event.stop(e);
}

On Aug 2, 11:19 am, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi Ashley,

 In the one that's not working, you're using what's called a DOM0-
 style handler -- that's where you're attaching the handler the old-
 fashioned way, by using an attribute on the form element:

     form id=password-form onsubmit=callProcBasketPassword()
  action=procBasketPasswordNoJS.php method=post

 Event.stop works only for handlers registered with more modern methods
 like the Event.observe you used with your first form.

 To correct the problem, I'd recommend using Event.observe to set up
 the handler for the second form as you did with the first.  If there's
 a reason you can't do that, though, the DOM0 equivalent of
 Event.stop is to return false from callProcBasketPassword.

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available

 On Aug 1, 4:35 pm, Ash ashley.kenner...@gmail.com wrote:

  Hi, I just started my first experiment with AJAX today. Got the basics
  working, but when I add a tiny bit more complexity I have a problem,
  Event.stop doesn't work properly for me.

  I've followed a couple of basic tutorials to submit an e-mail address
  to a PHP script, the PHP looks up the e-mail address and if it finds
  it, it shows an input to enter a password. This all works fine except
  the function with the ajax call to the password PHP script does not
  stop the form submitting.

  There is probably something very obvious I am doing wrong so hopefully
  someone will be able to spot this a mile away! :)

  The HTML looks like this, once the second form has been displayed

  form id=email-form action=procBasketEmailNoJS.php method=post
  input id=email class=texterwide type=text name=email/
  input id=email-submit class=button type=submit value=Submit/
  /form

  div id=email-response
     we have saved details on file for you, please enter your password
  below to retrieve them
     br/
     form id=password-form onsubmit=callProcBasketPassword()
  action=procBasketPasswordNoJS.php method=post
          input id=password class=texterwide type=text
  name=password/
          input id=password-submit class=button type=submit
  value=Submit/
     /form
  /div

  div id=password-response name=password-response/
  /div

  Here is the ajax.js

  // Attach handler to window load event
  Event.observe(window, 'load', init, false);

  function init(){
   Event.observe('email-form', 'submit', callProcBasketEmail);

  }

  function callProcBasketEmail(e) {
   var pars = Form.serialize('email-form');
   var myAjax = new Ajax.Updater('email-response',
  'procBasketEmail.php', {method: 'post', parameters: pars});
   Event.stop(e);

  }

  function callProcBasketPassword(e) {
   var pars = Form.serialize('password-form');
  var myAjax = new Ajax.Updater('password-response',
  'procBasketPassword.php', {method: 'post', parameters: pars});
   Event.stop(e);

  }

  When I step through in Firebug I can see that the password-response
  div gets filled with the results of the procBasketPassword.php script,
  but then the page tries to reload where the form is pointing

[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX

2009-08-03 Thread Ash

Thanks for the help, I just tried replacing Event.stop(e); with return
false; in the function but it still submits the form.

I would prefer to do it the new way anyway, if you would be able to
help me...

The first function is called from Event.observe('email-form',
'submit', callProcBasketEmail); which is within a function that is
called when the document loads.

The question is, where to put the event observe to watch the second
form.

My first instinct would be to put it in the function which outputs the
form EG


function callProcBasketEmail(e) {
 var pars = Form.serialize('email-form');
 var myAjax = new Ajax.Updater('email-response',
'procBasketEmail.php', {method: 'post', parameters: pars});
 Event.observe('password-form', 'submit', callProcBasketPassword);
 Event.stop(e);
}

(line added just after the ajax function has drawn 'password-form' to
the screen)

But this stops the whole function from working - where should the
observe line be placed to ensure it will work properly?

Thanks in advance, I think once I get over these initial few hurdles
of getting to grips with good practices, I will be fine!

Ashley


Here is the javascript in full:



// Attach handler to window load event
Event.observe(window, 'load', init, false);

function init(){
Event.observe('email-form', 'submit', callProcBasketEmail);
}

function callProcBasketEmail(e) {
 var pars = Form.serialize('email-form');
 var myAjax = new Ajax.Updater('email-response',
'procBasketEmail.php', {method: 'post', parameters: pars});
 Event.observe('password-form', 'submit', callProcBasketPassword);
 Event.stop(e);
}

function callProcBasketPassword(e) {
 var pars = Form.serialize('password-form');
 alert(pars);
 var myAjax = new Ajax.Updater('password-response',
'procBasketPassword.php', {method: 'post', parameters: pars});
 Event.stop(e);
}

On Aug 2, 11:19 am, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi Ashley,

 In the one that's not working, you're using what's called a DOM0-
 style handler -- that's where you're attaching the handler the old-
 fashioned way, by using an attribute on the form element:

     form id=password-form onsubmit=callProcBasketPassword()
  action=procBasketPasswordNoJS.php method=post

 Event.stop works only for handlers registered with more modern methods
 like the Event.observe you used with your first form.

 To correct the problem, I'd recommend using Event.observe to set up
 the handler for the second form as you did with the first.  If there's
 a reason you can't do that, though, the DOM0 equivalent of
 Event.stop is to return false from callProcBasketPassword.

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available

 On Aug 1, 4:35 pm, Ash ashley.kenner...@gmail.com wrote:

  Hi, I just started my first experiment with AJAX today. Got the basics
  working, but when I add a tiny bit more complexity I have a problem,
  Event.stop doesn't work properly for me.

  I've followed a couple of basic tutorials to submit an e-mail address
  to a PHP script, the PHP looks up the e-mail address and if it finds
  it, it shows an input to enter a password. This all works fine except
  the function with the ajax call to the password PHP script does not
  stop the form submitting.

  There is probably something very obvious I am doing wrong so hopefully
  someone will be able to spot this a mile away! :)

  The HTML looks like this, once the second form has been displayed

  form id=email-form action=procBasketEmailNoJS.php method=post
  input id=email class=texterwide type=text name=email/
  input id=email-submit class=button type=submit value=Submit/
  /form

  div id=email-response
     we have saved details on file for you, please enter your password
  below to retrieve them
     br/
     form id=password-form onsubmit=callProcBasketPassword()
  action=procBasketPasswordNoJS.php method=post
          input id=password class=texterwide type=text
  name=password/
          input id=password-submit class=button type=submit
  value=Submit/
     /form
  /div

  div id=password-response name=password-response/
  /div

  Here is the ajax.js

  // Attach handler to window load event
  Event.observe(window, 'load', init, false);

  function init(){
   Event.observe('email-form', 'submit', callProcBasketEmail);

  }

  function callProcBasketEmail(e) {
   var pars = Form.serialize('email-form');
   var myAjax = new Ajax.Updater('email-response',
  'procBasketEmail.php', {method: 'post', parameters: pars});
   Event.stop(e);

  }

  function callProcBasketPassword(e) {
   var pars = Form.serialize('password-form');
  var myAjax = new Ajax.Updater('password-response',
  'procBasketPassword.php', {method: 'post', parameters: pars});
   Event.stop(e);

  }

  When I step through in Firebug I can see that the password-response
  div gets filled with the results of the procBasketPassword.php script,
  but then the page tries to reload where the form is pointing

[Proto-Scripty] Beginners question, trouble with Event.stop in AJAX

2009-08-02 Thread Ash

Hi, I just started my first experiment with AJAX today. Got the basics
working, but when I add a tiny bit more complexity I have a problem,
Event.stop doesn't work properly for me.

I've followed a couple of basic tutorials to submit an e-mail address
to a PHP script, the PHP looks up the e-mail address and if it finds
it, it shows an input to enter a password. This all works fine except
the function with the ajax call to the password PHP script does not
stop the form submitting.

There is probably something very obvious I am doing wrong so hopefully
someone will be able to spot this a mile away! :)



The HTML looks like this, once the second form has been displayed


form id=email-form action=procBasketEmailNoJS.php method=post
input id=email class=texterwide type=text name=email/
input id=email-submit class=button type=submit value=Submit/
/form

div id=email-response
   we have saved details on file for you, please enter your password
below to retrieve them
   br/
   form id=password-form onsubmit=callProcBasketPassword()
action=procBasketPasswordNoJS.php method=post
input id=password class=texterwide type=text
name=password/
input id=password-submit class=button type=submit
value=Submit/
   /form
/div

div id=password-response name=password-response/
/div





Here is the ajax.js


// Attach handler to window load event
Event.observe(window, 'load', init, false);


function init(){
 Event.observe('email-form', 'submit', callProcBasketEmail);
}


function callProcBasketEmail(e) {
 var pars = Form.serialize('email-form');
 var myAjax = new Ajax.Updater('email-response',
'procBasketEmail.php', {method: 'post', parameters: pars});
 Event.stop(e);
}

function callProcBasketPassword(e) {
 var pars = Form.serialize('password-form');
var myAjax = new Ajax.Updater('password-response',
'procBasketPassword.php', {method: 'post', parameters: pars});
 Event.stop(e);
}



When I step through in Firebug I can see that the password-response
div gets filled with the results of the procBasketPassword.php script,
but then the page tries to reload where the form is pointing to -
action=procBasketPasswordNoJS.php.

Event.stop(e); works fine in the first function, but not in the second
one. Please can you help?

Thanks in advance.
Ashley

--~--~-~--~~~---~--~~
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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---