我正在尝试将 JSON 结果加载到表中的两列中:这是我的 HTML 代码:
<script>
var i;
$(document).ready(function(){
$.ajax({
type : "POST",
url : "http://localhost/ion/ver_comp.php",
async : true,
success : function(datos) {
var dataJson = eval(datos);
for ( i in dataJson) {
$("#content").append("<img src='"+dataJson[i].imagen+"' />");
}
},
error : function(obj, error, objError) {
//avisar que ocurrió un error
alert("ERROR DE CONEXION CON SERVIDOR");
}
});
});
</script>
</head>
<body>
<div id="content">
</div> <!-- /content -->
</body>
这是我的 JSON 代码(来自 PHP 脚本):
[
{
"cod": "1",
"nombre": "Target HR",
"imagen": "http://i.imgur.com/DFLF20G.png"
},
{
"cod": "2",
"nombre": "BCP",
"imagen": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcT3JhpDOH-cK-d2QF3RflbSc6dgb1ELCblX6UWiX63S3OzKST0r"
},
{
"cod": "3",
"nombre": "Gloria",
"imagen": "http://cdnimg.perulactea.com/wp-content/uploads/2009/08/Gloria1.JPG"
},
{
"cod": "4",
"nombre": "Cristal",
"imagen": "http://filmsperu.pe/New/Images/Noticias/content/CRISTAL_YR_15_06_2011/670x02.gif"
}
]
问题是在两列中显示“图像”(来自 json)。我只是不知道该怎么...
问候..