/ Published in: jQuery
URL: http://tobiascohen.com/files/stackoverflow/jquery-form-serializeObject.html
usage; $.toJSON($(\'form\').serializeObject());
Expand |
Embed | Plain Text
$.fn.serializeObject = function() { //Prepping for JSON var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; };
You need to login to post a comment.
