在senchatouch2中将数组作为查询字符串参数发送

时间:2013-04-08 12:06:43

标签: arrays post methods sencha-touch-2 query-string

如何使用POST方法在Ajax请求中将数组作为查询字符串参数发送,以访问第三方Web服务..

请提供示例代码..

2 个答案:

答案 0 :(得分:1)

虽然v使用POST方法在SenchaTouch2中发送参数,但在Ajax请求中使用 jsonData 而不是params,

Ext.Ajax.request({
url:'',
method:'POST',
disableCaching:false,
headers: {
          'Accept':'application/json',
          'Content-Type':'application/json'
         },
**jsonData**: {
           FirstName:fname  //{"FirstName":["Sam","paul"]}
              },
    success: function(response)
    {
        console.log(response.responseText);
    },
    failure: function(response)
    {
        console.log(response.responseText);
    }
});

答案 1 :(得分:0)

这是我通常的做法

...
params: {
  array: Ext.encode(['1', '2', '3'])
},
...

希望这有帮助