0
<html>
<head>
    <script src="jquery.js"></script>
    <script>
        $(document).ready(function() {
        $.ajax({
             cache: false,
             url:"http://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=eb6ffaa3fa419f01049c65f443ea1f08&user_id=87759985%40N04&format=json",
             type:"GET",
             contentType: "application/json",
             dataType: "text",
             timeout:3000,
             success: function(d, status, req)
             {
                alert(d);
                data = $.parseJSON(d);
                alert(data);
                var list = $("<ul></ul>");
                $.each(data.photosets.photoset, function (i, set) {
                    var link = $("<a/>").attr("title", set.description._content)
                        .attr("href", "http://www.flickr.com/photos/crazyeyes955/sets/" + set.id)
                        .text(set.title._content);
                    var li = $("<li/>").append(link).append(" (" + set.photos + ")");
                    $(list).append(li);
                });
              $("flicker_sets").text($.parseJSON(d).x);
             },
             error: function(req, status, err)
             {
                alert("Failed...");
              $("#result").text(req.responseText);
             }
            })
        // selectors
        // # = id
        // . = class
        });
    </script>
</head>
<body>
    <div id = "flicker_sets">
    </div>
</body>

这是我到目前为止拼凑的脚本。我什至无法显示警报。jquery 文件在同一个文件中,我只是在 chrome 上运行它。FireFox 显示了同样的情况。有任何想法吗?

4

1 回答 1

0

您在请求中指定了这一点..

dataType: "text",

尝试将其更改为

dataType: "json",
于 2012-10-03T02:25:50.197 回答