如何使用json响应创建滑块

时间:2018-09-24 06:51:26

标签: javascript

Json数据

{"code":1,
 "msg":"OK",
 "details":{"gallery_photo": ["https:\/\/www.yourdomain.in\/upload\/tet.jpg","https:\/\/www.yourdomain.in\/upload\/tet.jpg","https:\/\/www.yourdomain.in\/upload\/tet.jpg"]}}

我正在以Case模式存储数据

case "getItemDetails":

                displayItemGall(data.details);

            break;

我创建的函数无法创建循环

    function displayItemGall(data)
{       
var gallery = JSON.parse(data).gallery_photo;
        var html_gallery='';
                $.each(gallery, function( key, val ) {
                        html_gallery+='<a>';
                        html_gallery+='<img src="'+val+'" data-src="'+val+'" class="preload-image responsive-image" alt="img">';
                        html_gallery+='</a>';

                   });

                   createElement("item-info2",html_gallery);
}

0 个答案:

没有答案