Quiero recorrer este Json para obtener sus valores y mostrarlos
[
{
"$id": "1",
"Nombre": "Casa de las Conservas",
"Descripcion": "",
"Imagen": "",
"Destino": "San Miguel de Allende",
"Url": "https://www.mexicodestinos.com/san-miguel-de-allende/hoteles/casa-de-las-conservas.html",
"PrecioDesde": 0,
"PrecioDesdePromo": 0,
"TienePromo": 0,
"Servicio": "Hotel"
},
{
"$id": "2",
"Nombre": "Misión San Miguel de Allende",
"Descripcion": "Este confortable y acogedor ho",
"Imagen": "https://cdn.mexicodestinos.com/hoteles/hotel-mision-san-miguel-de-allende-princ.jpg",
"Destino": "San Miguel de Allende",
"Url": "https://www.mexicodestinos.com/san-miguel-de-allende/hoteles/hotel-mision-san-miguel-de-allende.html",
"PrecioDesde": 568,
"PrecioDesdePromo": 540,
"TienePromo": 1,
"Servicio": "Hotel"
},
{
"$id": "3",
"Nombre": "Misión San Miguel de Allende",
"Descripcion": "Este confortable y acogedor ho",
"Imagen": "https://cdn.mexicodestinos.com/hoteles/hotel-mision-san-miguel-de-allende-princ.jpg",
"Destino": "San Miguel de Allende",
"Url": "https://www.mexicodestinos.com/san-miguel-de-allende/hoteles/hotel-mision-san-miguel-de-allende.html",
"PrecioDesde": 568,
"PrecioDesdePromo": 540,
"TienePromo": 1,
"Servicio": "Hotel"
},
{
"$id": "4",
"Nombre": "Belmond Casa De Sierra Nevada",
"Descripcion": "Belmond Casa de Sierra Nevada,",
"Imagen": "https://cdn.mexicodestinos.com/hoteles/casa-de-sierra-nevada-san-miguel-de-allende-princ.jpg",
"Destino": "San Miguel de Allende",
"Url": "https://www.mexicodestinos.com/san-miguel-de-allende/hoteles/belmond-casa-de-sierra-nevada.html",
"PrecioDesde": 0,
"PrecioDesdePromo": 0,
"TienePromo": 0,
"Servicio": "Hotel"
},
{
"$id": "5",
"Nombre": "Misión San Miguel de Allende",
"Descripcion": "Este confortable y acogedor ho",
"Imagen": "https://cdn.mexicodestinos.com/hoteles/hotel-mision-san-miguel-de-allende-princ.jpg",
"Destino": "San Miguel de Allende",
"Url": "https://www.mexicodestinos.com/san-miguel-de-allende/hoteles/hotel-mision-san-miguel-de-allende.html",
"PrecioDesde": 568,
"PrecioDesdePromo": 540,
"TienePromo": 1,
"Servicio": "Hotel"
}
]
Realicé el siguiente código
$.ajax({
data: parametros,
type:"POST",
url:"cUrl.php",
success: function(res){
//console.log(data);
for(i=0;i<res.length;i++){
$('#lol').html("<strong><p>"+res[i]['Nombre']+"</p></strong>");
}
}
});
Pero me devuelve valores undefine
for
recorre un arreglo de json, ya que lo he probado y funciona correctamente$.ajax({ //data: parametros, type: "POST", url: "cUrl.php", contentType: "application/json; charset=utf-8", dataType: "json", success: function (res) { //console.log(data); var lst = JSON.parse(res.d); for (i = 0; i < lst.length; i++) { $('#lol').html("<strong><p>" + lst[i]['Nombre'] + "</p></strong>"); } } });