我有一个用Ruby编写的API代码,它在循环中的请求中调用API,因为我们最多可以得到50个结果。但我想在jQuery中创建这个API请求。我不知道我将如何做到这一点。如何在jQuery中获取和发布API请求?
这里是我的Ruby代码:
totalsequence = []
start = 0
begin
response = HTTParty.get("https://api.ontraport.com/1/objects?objectID=5&start=" + start.to_s,
{
:headers => { 'Api-Appid' => '', 'Api-Key' => ''}
})
totalsequence = totalsequence + response['data']
start += 50
end until (response['data']).size == 0
render json: JSON.pretty_generate(totalsequence)
所以我想这个代码转换为jQuery的。
我不是你问清楚了吗? – MZaragoza
如果只是将上面的代码转换为jQuery,快速谷歌搜索会导致大量代码示例。 – Sid
[jQuery Ajax简单调用]的可能重复(http://stackoverflow.com/questions/19015897/jquery-ajax-simple-call) –