0
JSON看起来是这样的:如何对数组进行排序并使用HTML进行换行?
[{"title":"Modern\/Contemporary House of mine.","link":"http:\/\/buildworx-mc.com\/forum\/showthread.php?tid=1718","images":["http:\/\/i1139.photobucket.com\/albums\/n555\/xDJBOUTIx\/house1.png","http:\/\/i1139.photobucket.com\/albums\/n555\/xDJBOUTIx\/House2.png","http:\/\/i1139.photobucket.com\/albums\/n555\/xDJBOUTIx\/House3.png","http:\/\/i1139.photobucket.com\/albums\/n555\/xDJBOUTIx\/House4.png","http:\/\/i1139.photobucket.com\/albums\/n555\/xDJBOUTIx\/House5.png","http:\/\/i1139.photobucket.com\/albums\/n555\/xDJBOUTIx\/House6.png"]}
我能拿到冠军,并链接就好了。但我无法得到图像,因为在一些有多个链接。
我试图让每一个图像链接到被包裹在HTML。
$.getJSON("gallery/getScreenshots.php", function (data) {
$.each(data, function (i, image) {
var link = image.link, title = image.title. images = image.images;
$img = $('<img>').attr('src', images);
$('#screenshots').append($img);
});
但结果是这样的:
<img src="http://i1139.photobucket.com/albums/n555/xDJBOUTIx/house1.png,http://i1139.photobucket.com/albums/n555/xDJBOUTIx/House2.png,http://i1139.photobucket.com/albums/n555/xDJBOUTIx/House3.png,http://i1139.photobucket.com/albums/n555/xDJBOUTIx/House4.png,http://i1139.photobucket.com/albums/n555/xDJBOUTIx/House5.png,http://i1139.photobucket.com/albums/n555/xDJBOUTIx/House6.png" alt="">
我如何排序整个数组,然后获得每个图像追加到<img>?
我用你的,我得到未捕获的SyntaxError:意外的标记, – nowayyy 2012-03-01 03:12:58
其实没关系,谢谢! – nowayyy 2012-03-01 06:02:53