Created
October 25, 2015 10:32
-
-
Save andrIvash/457c24d4c769652c7964 to your computer and use it in GitHub Desktop.
Post form data
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
function postFormData(form, successCallback) { | |
var | |
host = form.attr('action'), | |
reqFields = form.find('[name]'), | |
dataObject = {}; | |
if (!host) { | |
console.log('set action attribute to your form, you fool!!'); | |
} | |
reqFields.each(function(){ | |
var | |
$this = $(this), | |
value = $this.val(), | |
name = $this.attr('name'); | |
dataObject[name] = value; | |
}); | |
$.post(host, dataObject, successCallback); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment