Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何对数组进行排序并用HTML包装每个数组?_Javascript_Jquery_Json - Fatal编程技术网

Javascript 如何对数组进行排序并用HTML包装每个数组?

Javascript 如何对数组进行排序并用HTML包装每个数组?,javascript,jquery,json,Javascript,Jquery,Json,JSON如下所示: [{"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

JSON如下所示:

[{"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);

   });
$.getJSON(“gallery/getScreenshots.php”,函数(数据){
$。每个(数据、函数(i、图像){
var link=image.link,title=image.title.images=image.images;
$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="">


如何对数组进行排序并使用
$将每个图像附加到

中。每个
循环:

$.each(images, function(i,el) {
    $('#screenshots').append($('<img>',{'src',el}));
});
$。每个(图像、函数(i、el){
$('#屏幕截图')。附加($('Hell Trippy

这是下面的代码和工作演示

var信息=[
{
“标题”:“现代/当代我的房子”,
“链接”:http://buildworx-mc.com/forum/showthread.php?tid=1718",
“图像”:[
"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"
]
}
];
var album=info[0][“图像”];

对于(i=0;我使用了你的,我得到了未捕获的语法错误:意外标记,
var info=[
    {
        "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"
        ]
    }
];
var album=info[0]["images"];
for(i=0;i<album.length;i++)
{  console.log(album[i]);
  $('#screenshots').append($('<img>').attr('src', album[i])                                    
                      .css({'width':'200px','height':200px'}));
}