<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 显示了同样的情况。有任何想法吗?