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);
}