[jQuery] Re: Updating input values before the submit.

2007-12-20 Thread Jake McGraw
Ah do you have a copy of the form, so I can see exactly what you're doing?

- jake

On Dec 18, 2007 7:29 PM, Jesse R. <[EMAIL PROTECTED]> wrote:

>
> The request is still failing.  Any other ideas?
>
> On Dec 18, 11:37 am, "Jake McGraw" <[EMAIL PROTECTED]> wrote:
> > The problem is that the form is actually submitting before you can get a
> > response, this is the nature of an asynchronous request (the first A in
> > AJAX). Perhaps you could bind the the submit to one of the callbacks:
> >
> > jQuery("#googleCheckout").submit(function() {
> > var $form = jQuery(this);
> > if (!$form.is(".okgo")) {
> > jQuery.ajax({
> > type: "POST",
> > dataType: "json",
> > url: "/json-checkout",
> > error: function(){
> > // Do nothing, "okgo" not added
> > },
> > success: function(json){
> > jQuery("input:first").val(json.gec);
> > jQuery("input:eq(1)").val(json.ges);
> > // This will prevent the AJAX message from being sent
> again
> > $form.addClass("okgo");
> > // Successful AJAX message, re-submit, this time for
> real
> > $form.submit();
> > }
> > });
> > return false;
> > }
> >
> > });
> >
> > On Dec 18, 2007 11:27 AM, Jesse R. <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > I have the following html code:
> >
> > > https://sandbox.google.com/checkout/
> > > cws/v2/Merchant/747474/checkout" method="post">
> > > 
> > > 
> > >  > > src="https://sandbox.google.com/checkout/buttons/checkout.gif?
> >
> > >
> merchant_id=747474&w=160&h=43&style=WHITE&variant=TEXT&loc=en_US
> > > "
> > > height="43" width="160" />
> > > 
> >
> > > I want to dynamically load those values with a json request
> > > immediately before the submit, but not any sooner.  I tried doing the
> > > following code:
> >
> > > jQuery("#googleCheckout").submit(function() {
> > > jQuery.ajax({
> > >   type: "POST",
> > >   dataType: "json",
> > >   url: "/json-checkout",
> > >   error: function(){return false;},
> > >   success: function(json){
> > >jQuery("input:first").attr({
> > >value: json.gec
> > >});
> > >jQuery("input:eq(1)").attr({
> > >value: json.ges
> > >});
> > >return true;
> > >}
> > >   });
> > > });
> >
> > > However, the ajax request fails according to Firebug and the submit
> > > contains the old data.  The requested URL is
> > >http://www.blueskyvineyard.com/json-checkout.
> > > Any suggestions would be greatly appreciated!
>


[jQuery] Re: Updating input values before the submit.

2007-12-18 Thread Jesse R.

The request is still failing.  Any other ideas?

On Dec 18, 11:37 am, "Jake McGraw" <[EMAIL PROTECTED]> wrote:
> The problem is that the form is actually submitting before you can get a
> response, this is the nature of an asynchronous request (the first A in
> AJAX). Perhaps you could bind the the submit to one of the callbacks:
>
> jQuery("#googleCheckout").submit(function() {
> var $form = jQuery(this);
> if (!$form.is(".okgo")) {
> jQuery.ajax({
> type: "POST",
> dataType: "json",
> url: "/json-checkout",
> error: function(){
> // Do nothing, "okgo" not added
> },
> success: function(json){
> jQuery("input:first").val(json.gec);
> jQuery("input:eq(1)").val(json.ges);
> // This will prevent the AJAX message from being sent again
> $form.addClass("okgo");
> // Successful AJAX message, re-submit, this time for real
> $form.submit();
> }
> });
> return false;
> }
>
> });
>
> On Dec 18, 2007 11:27 AM, Jesse R. <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have the following html code:
>
> > https://sandbox.google.com/checkout/
> > cws/v2/Merchant/747474/checkout" method="post">
> > 
> > 
> >  > src="https://sandbox.google.com/checkout/buttons/checkout.gif?
>
> > merchant_id=747474&w=160&h=43&style=WHITE&variant=TEXT&loc=en_US
> > "
> > height="43" width="160" />
> > 
>
> > I want to dynamically load those values with a json request
> > immediately before the submit, but not any sooner.  I tried doing the
> > following code:
>
> > jQuery("#googleCheckout").submit(function() {
> > jQuery.ajax({
> >   type: "POST",
> >   dataType: "json",
> >   url: "/json-checkout",
> >   error: function(){return false;},
> >   success: function(json){
> >jQuery("input:first").attr({
> >value: json.gec
> >});
> >jQuery("input:eq(1)").attr({
> >value: json.ges
> >});
> >return true;
> >}
> >   });
> > });
>
> > However, the ajax request fails according to Firebug and the submit
> > contains the old data.  The requested URL is
> >http://www.blueskyvineyard.com/json-checkout.
> > Any suggestions would be greatly appreciated!


[jQuery] Re: Updating input values before the submit.

2007-12-18 Thread Jake McGraw
The problem is that the form is actually submitting before you can get a
response, this is the nature of an asynchronous request (the first A in
AJAX). Perhaps you could bind the the submit to one of the callbacks:

jQuery("#googleCheckout").submit(function() {
var $form = jQuery(this);
if (!$form.is(".okgo")) {
jQuery.ajax({
type: "POST",
dataType: "json",
url: "/json-checkout",
error: function(){
// Do nothing, "okgo" not added
},
success: function(json){
jQuery("input:first").val(json.gec);
jQuery("input:eq(1)").val(json.ges);
// This will prevent the AJAX message from being sent again
$form.addClass("okgo");
// Successful AJAX message, re-submit, this time for real
$form.submit();
}
});
return false;
}
});

On Dec 18, 2007 11:27 AM, Jesse R. <[EMAIL PROTECTED]> wrote:

>
> I have the following html code:
>
> https://sandbox.google.com/checkout/
> cws/v2/Merchant/747474/checkout" method="post">
> 
> 
>  src="https://sandbox.google.com/checkout/buttons/checkout.gif?
>
> merchant_id=747474&w=160&h=43&style=WHITE&variant=TEXT&loc=en_US
> "
> height="43" width="160" />
> 
>
> I want to dynamically load those values with a json request
> immediately before the submit, but not any sooner.  I tried doing the
> following code:
>
>
> jQuery("#googleCheckout").submit(function() {
> jQuery.ajax({
>   type: "POST",
>   dataType: "json",
>   url: "/json-checkout",
>   error: function(){return false;},
>   success: function(json){
>jQuery("input:first").attr({
>value: json.gec
>});
>jQuery("input:eq(1)").attr({
>value: json.ges
>});
>return true;
>}
>   });
> });
>
> However, the ajax request fails according to Firebug and the submit
> contains the old data.  The requested URL is
> http://www.blueskyvineyard.com/json-checkout.
> Any suggestions would be greatly appreciated!
>