我有这样的数据:
data = { someID: Number, someList: [ {a:1,b:2} {a:2, b:3} ] }
我想使用$ .ajax使GET请求sutch为:
?someID=Number&a=1&b=2&a=2&b=3
有人能指点我更好的方法吗?
var url = '?someID='+data['someID']; for (l in data['someList']) { url += '&a=' + data['someList'][l]['a'] + '&b=' + data['someList'][l]['b']; } $.ajax({ url: #your url, 'Content-Type' : 'application/json', 'dataType' : 'json' }) .done(function (resp) { # your done function });
当然,如果您知道所有索引,所有这些都是可能的 .
1 回答
当然,如果您知道所有索引,所有这些都是可能的 .