Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ajax.Request vs. action

    I am having a heck of time getting a form to both make an Ajax request and submit to the forms action parameter.

    I have a script that is supposed to collect form data with http request, then submit through to paypal.

    The function is setup as a submit event using Prototypes observe method.
    When submit it clicked, the following is run.

    Code:
    function submitReg(formid) {
    	var form	=	formid.target;
    	var	params	=	{};
    	params['first']		=	$F('first');
    	params['last']		=	$F('last');
    	params['email']		=	$F('email');
    	//$(form).action	=	"https://www.paypal.com/cgi-bin/webscr";
    	var url	=	'/sendReg';
    	
    	new Ajax.Request(url, {
    		method: 'post',
    		parameters: params,
    		onComplete: function(tran) {
    			alert('sent');
    		}
    	});
    }
    Problem is, the form just goes to the action parameter. If I set the form to false, it goes no where but the ajax request is made.

    I cannot seem to figure this out and spent hours trying out different combos of inline handlers, returning false, returning true... Im going mad with this.

    Any help would be huge!!
    Thanks
    Rich

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    so have your request call your function onsuccess. or, oncomplete have it fire conditionally based on the return value.

    also, check out http://www.prototypejs.org/api/form/serialize


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •