我在通过 json 循环时遇到问题。
在下面的代码中,循环的 url 是无序的,并且警报中的 id 始终是 3。有人可以告诉我我在这里做错了什么吗?
var urls = ["http://soundcloud.com/disclosuremusic/sets/the-face-ep-1", "http://soundcloud.com/skibsthekid/sets/the-pink-slip", "http://soundcloud.com/disclosuremusic/sets/the-face-ep-1"];
for (var i = 0, url; url = urls[i]; i++) {
console.log(i);
$.getJSON('http://api.soundcloud.com/resolve?url=' + url + '&format=json&consumer_key=' + consumer_key, function(playlist) {
alert(i + playlist.title);
});
}