$.post( "/factory/set",{ key : value },function(response) { }); },"json" );
哪里
key = "foo" value = "bar"
但是服务器总是得到“key”和“bar”,有没有办法将key设置为variable,而不是string?
var data = {};
然后设置属性:
data[key] = value;
然后在调用$.post()中使用该对象:
$.post( "/factory/set",data,function(response) { },"json" );