Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Last active December 25, 2015 10:49
Show Gist options
  • Save khoand0000/2acb66a11981125ecf0f to your computer and use it in GitHub Desktop.
Save khoand0000/2acb66a11981125ecf0f to your computer and use it in GitHub Desktop.
shared.js
function extractFormData(selector, data) {
$.each($(selector).serializeArray(), function (i, field) {
data[field.name] = field.value;
});
}
/**
* usage: var $arr = {a: 1, b: 4}; empty($arr['test']); // true
*/
function empty($var) {
return typeof $var === typeof undefined;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment