Im using YII and it sends the data as "table[attr1]=1&table[attr2]=2&table[attr3]=3" so to make a request using jquery I use:
$.ajax({
url:"url",
data:{
'table[attr1]':1,
'table[attr2]':2,
'table[attr3]':3,
},
success:function(resp){
//ok
}
});
but I need to make this data json dynamicaly, I tryed this but dosent work:
$("input").each(function(){ //build the data json
form.table[this.name]=this.value; //the name is 'attr1' , the value is 1
});
$.ajax({
url:"url",
data:form, //send the JSON here
success:function(resp){
//ok
}
});
This will send the data empty
Any ideas how to build this json?