Link to home
Start Free TrialLog in
Avatar of paldie
paldieFlag for United States of America

asked on

jQuery Form Plugin Won't Submit

I am building an application with a lot of jQuery that runs on Sean Corfield's Framework 1 in ColdFusion.  A lot of forms in the application use jQuery to submit via ajax and validate client side using the Vanadium library.

I recently decided that to unify the forms a little better I would add the jQuery Form plugin.  I thought it was working for a little while, but now I am noticing that the validation in my function runs just fine and then nothing happens after that... the ajaxForm function never runs.

I am submitting the form by using an a link that runs submitForm('formid') onclick.  I found  that I when I used a href="javascript:submitForm('formid') it would actually navigate to www.domain.com/submitForm('formid').
function submitForm(formid){
	$form = $('#' + formid)
	alert('Form with ID of ' + formid + ' was submitted.');
	// Show the form loader
	$('#' + formid + ' .form-loader').fadeIn('slow');
	$('#' + formid + ' #main-advice').remove();
	// Validate the form... just in case
	Vanadium.validateAndDecorate()
	// Check if the form has any errors
	if($('#' + formid + '.vanadium-advice').length){
		// If so then add an error message
		$('#' + formid + '.formBlock').prepend('<span class="vanadium-advice" id="main-advice">Please review errors below and then submit again.</span>').css('align','center');
		$('#' + formid + '.form-loader').fadeOut('slow');
		return false;
	}
	try {
		$form.ajaxForm({
			success: function(){
				alert('Hello World');
			},
			error: function(e){
				alert(e);
			}
		});
	} catch(e){
		alert(e.description);
	}
	return true;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of paldie
paldie
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial