Created
December 1, 2014 14:04
-
-
Save ksloan/f2c663db4c8d941cb1da to your computer and use it in GitHub Desktop.
jQuery plugin to turn form in JSON
This file contains hidden or 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
$.fn.form2JSON = function() { | |
var data = {} | |
this.serializeArray().map(function(item) { | |
data[item.name] = item.value; | |
}); | |
return data | |
} | |
// use like this | |
var data = $form.form2JSON() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment