Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2009, 07:12 PM   PM User | #1
richtestani
New to the CF scene

 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
richtestani is an unknown quantity at this point
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
richtestani is offline   Reply With Quote
Old 03-25-2009, 03:01 PM   PM User | #2
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
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
ohgod is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:46 AM.


Advertisement
Log in to turn off these ads.