i have serialize array like this
rate_3=26&rate_8=67&rate_12=98
etc..,
now i need to change this array as json type
{
"ID": "3",
"Rate": "26"
},
{
"ID": "8",
"Rate": "67"
},
{
"ID": "3",
"Rate": "26"
} ..,
etc
so i tried like this but its not working... please some one help me.
var o = {};
var a = table.$('input, select').serialize();
$.each(a, function()
{
if (o[this.name] !== undefined)
{
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;
i m using datatable so i just need to get Datatables serialize array only for that used this line
var a = table.$('input, select').serialize();
even i tried with json2.js also but when i use json2.js it forcing the page to submit
var data_2 = JSON.stringify(block_form.serializeArray());