jQuery Tokeninput发送回json

时间:2015-05-11 09:07:12

标签: javascript jquery ajax json jquery-tokeninput

我使用jQuery Tokeninput接收类别列表。它看起来像这样:

{id: 1, type: 1, name: "Category1"},
{id: 2, type: 2, name: "Category2"},
{id: 3, type: 1, name: "Category3"},
{id: 4, type: 1, name: "Category4"},
{id: 5, type: 2, name: "Category5"}

然后我想用ajax将选定的令牌发送回服务器,但我只能发送带有ID或类型或名称的数组。我需要发送与收到的相同的JSON,相同的结构和格式,但只选择令牌。

我试图使用tokenValue参数,但它只想要1个参数,你不能告诉他构建JSON。

1 个答案:

答案 0 :(得分:0)

使用POST方法将阵列发送到服务器。并在参数上使用JSON.stringify()方法后将数组发送到服务器。