我试图通过转换我建造的查询Instagram的香草JavaScript提要解析器在CoffeeScript我的手。我一直在靠近墙壁试图让逻辑在for循环中工作,我可以通过web上的100个示例获得一个简单的for循环,但我还没有得到一个for循环中有更多的代码。我接近完全错误吗?我传递给函数的参数“results”是一个JSON对象。for循环在咖啡脚本
_feed: (results) ->
images = results.length
for img in images
a = document.createElement('a');
a.href = results.data[i].images.standard_resolution.url;
img = document.createElement("img");
img.src = results.data[i].images.low_resolution.url;
a.appendChild(img);
document.getElementsByTagName('body')[0].appendChild(a);
我不断收到错误,说出意外的超时。有小费吗?
如果'results.data'是一个对象,它不应该是'for..of'吗? – elclanrs 2013-03-06 02:11:11
@elclanrs:是不是'results.data'数组?我认为这是一个数组。 – Blender 2013-03-06 02:12:05
哦,也许我误会了... OP说'results'是一个JSON对象...为了 – elclanrs 2013-03-06 02:13:31