0
目前我做一些代码重构,并尝试通过concatentation取代一代查询字符串,以JSON对象的序列化序列化数组查询字符串参数
来源:
$.ajax({
url:'./services/DataService/getDetails?metric=9&'+dashBoards.getFilter()+'groupby=quarter&'+dashBoards.options.time.start1+'&'+dashBoards.options.time.end1+'&peergroup='+dashBoards.options.peerGroup,
type:"GET",
要:
$.ajax({
url:'./services/DataService/getDetails',
data: jsonObject,
type:"GET",
几乎一切正常,除了一件事情。如果jsonObject
包含数组字段,它看起来在查询字符串这样的:
...?metric[]=1&metric[]=3
而不是
...?metric=1&metric=3
有没有办法,我该如何解决?谢谢!
你必须在'POST'类型的数据传递而不是'GET'和阿贾克斯'data'你可以把它像你所提到的。你也可以像'data:JSON.stringify(jsonObject)'那样做,并使用'POST'类型。 –
@ParthTrivedi'JSON.stringify'不需要,OP不发送JSON – Hacketo
只有改变'type:“GET”'到'type:“POST”' –