私は次のjqueryを持っています:
var xj=[{"name":"person","id":1},{"name":"jack", "id":2}];
$.post('/hex-jt/locations',xj , function(data){
console.log("this posted");
},'json');
それは大丈夫だと思われます。しかし、それは私のレールアプリに次のように渡されます:
これで何が起こっているのですか?
私は次のjqueryを持っています:
var xj=[{"name":"person","id":1},{"name":"jack", "id":2}];
$.post('/hex-jt/locations',xj , function(data){
console.log("this posted");
},'json');
それは大丈夫だと思われます。しかし、それは私のレールアプリに次のように渡されます:
これで何が起こっているのですか?
Stringjquery.post()
またはPlainObject
.
jQuery.post( url [, data ] [, success(data, textStatus, jqXHR) ] [, dataType ] )
data
Type: PlainObject or String
A plain object or string that is sent to the server with the request.
たとえば、配列をオブジェクトにラップして、次のように変更できます。
xj={"users":[{"name":"person","id":1},{"name":"jack", "id":2}]};