Quantcast
Channel: Adclick IT Blog » snippet
Viewing all articles
Browse latest Browse all 4

jQuery Serialize form to JSON

$
0
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$.fn.serializeObject = function()
{
   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;
};

Viewing all articles
Browse latest Browse all 4

Trending Articles