我想從flickr rss獲取圖像,但此代碼不會獲取它們。 這就是我在這裏得到一些幫助後所得到的結果:Jquery in Internet Explorer: find image problem(works in FF and Chrome)從另一個域的rss獲取圖像(然後附加它)
問題是以正確的格式獲取數據到我的網頁。 我的網址是:zalastax.co.cc/pictures.html
的Javascript:
$.ajax({
type: "GET",
url: "js/getflickreasy.php",
dataType: "xml",
success: function(data) {
$(data).find("item").each(function() {
var item = $(this), title, description, thumbnail;
title = item.find("title").text();
description = item.find("description").text();
thumbnail = item.find("img").attr("src");
});
}
});
PHP:
<?
header("content-type: text/xml");
readfile("http://api.flickr.com/services/feeds/[email protected]&lang=en-us&format=xml");
?>
編輯:馬修斯代碼工作。
但我有一個附加一些數據的問題。
var currentImage = 0;
//get flicker images from rss.
$.getJSON("http://api.flickr.com/services/feeds/[email protected]&lang=en-us&format=json&jsoncallback=?", function(data) {
$(data.items).each(function() {
var item = this,
title, description, thumbnail;
title = item.title;
description = item.description;
thumbnail = item.media.m;
if (currentImage % 3 === 0) {
$("#apa").append("<p>HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH</p>");
}
currentImage++;
$("#apa").append("<div id=\"div" + currentImage + "\" class=\"imageContainer pictDiv\"><img id=\"img" + currentImage + "\" class=\"bild pictImg\" src=\"" + thumbnail + "\" /></div>");
$("#bakgrund").append("<img id=\"bkg" + currentImage + "\" class=\"bgrund pictBkg\" src=\"Bilder/polaroid.png\" />");
});
$("#bakgrund").append("<img id=\"bkg" + currentImage + "\" class=\"bgrund pictBkg\" src=\"Bilder/polaroid.png\" />");
});
此代碼適用於Google Chrome。在Firefox中,它檢索數據但不做附加。 如果我嘗試追加其他內容,如簡單文本,Firefox不會追加。
它在我通過jsfiddle.net嘗試它時起作用,但它通過我自己的網頁嘗試時不起作用。
這對我在Firefox中的工作正常 - http://jsfiddle.net/tBAXV/ – Sam 2010-11-18 17:21:42
我知道,它通過小提琴使用它,但它在我的網頁中使用它時不起作用。我嘗試了全部源代碼,只有這個源代碼,它不會追加。在http://www.zalastax.co.cc/pictures.html查看它。 – Zalastax 2010-11-18 19:56:23