0

Hi have this code but it's throwing an error. How can I output some of the items within the feed?

var jsonSoundCloudFeed = "http://api.soundcloud.com/users/pete-snodden/tracks.json?client_id=a27703be6852256590c1921c5f8c7281";

            $.ajax({
                url: jsonSoundCloudFeed,
                data: {},
                dataType: "jsonp",
                callbackParameter: "jsoncallback",
                timeout: 5000,
                success: function(data){
                    $.each(data.kind, function(i, item) {

                        alert('yo');
                    });
                },
                error: function(XHR, textStatus, errorThrown){
                    console.log("ERROR: " + textStatus);
                    console.log("ERROR: " + errorThrown);
                }
            });
4

2 回答 2

0

只需将处理程序中的each-block更改为success如下所示:

$.each(data, function(i, item) {
    alert(i + " " + item.kind);
});

有关整个代码,请参阅此 JSfiddle 。

于 2012-09-13T10:24:59.393 回答
0

Like j0nes said, there's a bug in your success handler, but that's probably not even being executed: for JSONP, the extension should be ".js" instead of ".json".

于 2012-09-13T23:14:36.300 回答