/ Published in: jQuery
usage; $.toJSON($(\'form\').serializeObject());
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$.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; };
URL: http://tobiascohen.com/files/stackoverflow/jquery-form-serializeObject.html