Created
December 23, 2015 06:28
-
-
Save sravan-s/fd8244cb408e8d792224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AjaxForm = function(formId) { | |
var form = document.getElementById(formId), | |
postLoc = Drupal.absoluteUrl(jQuery(form).attr('action')), | |
submit = jQuery(form).find('[type="submit"]'); | |
submit.click(function(e) { | |
e.preventDefault(); | |
if(form.validator) { | |
if(form.validate()) { | |
jQuery.post(postLoc, jQuery(form).serialize()); | |
} | |
} else { | |
jQuery.post(postLoc, jQuery(form).serialize()); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment