2

私は次のjqueryを持っています:

  var xj=[{"name":"person","id":1},{"name":"jack", "id":2}];
  $.post('/hex-jt/locations',xj , function(data){
    console.log("this posted");
  },'json');

それは大丈夫だと思われます。しかし、それは私のレールアプリに次のように渡されます:

ここに画像の説明を入力

これで何が起こっているのですか?

4

1 に答える 1

1

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}]};
于 2013-09-07T02:09:53.170 に答える