【发布时间】:2013-01-31 19:25:31
【问题描述】:
我正在使用 YII,它以“table[attr1]=1&table[attr2]=2&table[attr3]=3”的形式发送数据,以便使用我使用的 jquery 发出请求:
$.ajax({
url:"url",
data:{
'table[attr1]':1,
'table[attr2]':2,
'table[attr3]':3,
},
success:function(resp){
//ok
}
});
但是我需要动态地使这个数据 json,我尝试了这个但是没有用:
$("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
}
});
这将发送空数据
任何想法如何构建这个 json?
【问题讨论】: