[Javascript] Two Actions with one form

Paul Novitski paul at novitskisoftware.com
Sun Mar 26 17:04:57 CST 2006


At 02:05 PM 3/26/2006, Matt Warden wrote:
>Often you can make a return page from payment sites like paypal. These
>will either post back all the content, or return it to you in the
>query string. You might be able to do this with paypal. I would check
>that first.

You can do this, however if something goes wrong before the return 
page renders -- either the user cancels the transaction or PayPal 
fails or the return page redirect fails for any reason -- then the 
original client's system will not know that a transaction attempt has occurred.

Better, I think, to record the submit attempt and the paypal return 
event to get the complete picture, so you can scoop up those 
customers who fall through the cracks.


>Your other option is to submit to the form contents to your CGI with
>something like XMLHTTP/AJAX, and then allow the form to post to
>paypal.

I had suggested using an Image object simply because I thought it 
would be more backward- and cross-browser compatible than 
XmlHttpRequest.  Since in this case the goal of calling the CGI 
script is to send data and not to receive it, I question the use a 
technology created to receive data that only the latest browsers support.

On the other hand -- what happens when the CGI script detects errors 
in the input data?  How does it notify the user?  That senario argues 
for a data flow model that requires the server-side script to execute 
successfully BEFORE submitting the form to paypal.

I'd check the PayPal documentation to see if their engine can be 
engaged by both GET or POST.  If so, it would be simple enough to use 
redirect from CGI instead of submit from the original HTML.

Another model I prefer is to submit the form to a server-side script 
for validation & database writing, then if all is OK generate a 
confirmation page for the user that displays the order information 
and contains hidden fields with all the PayPal data fields, with a 
submit button to proceed.  Such a confirmation page can be comforting 
for the user and developer alike.

Regards,
Paul 




More information about the Javascript mailing list