Created
July 5, 2017 22:02
-
-
Save kodamirmo/a274f08acc98154d3a83207cd1969922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var template = '<div><span> <%= nombre %> </span><p><%= descripcion %></p><h4><%= precio %></h4><img src="<%= imagen %>"/></div>'; | |
var compiled = _.template(template); | |
function createExperience(data) { | |
return compiled(data); | |
} | |
var xhr = $.ajax({ | |
url: "http://52.26.247.55:8080/EWS/web/kit", | |
method: "GET", | |
}).done(function(respuesta) { | |
var arregloExperiencias = respuesta.data; | |
arregloExperiencias.forEach(function(experiencia){ | |
console.log( "Experiencia: ", experiencia ); | |
var dataToUnderscore = { | |
nombre : experiencia.attributes.kit, | |
descripcion : experiencia.attributes.descripcion, | |
imagen : experiencia.attributes.imagen, | |
precio : '$' + experiencia.attributes.precio | |
}; | |
var htmlElement = createExperience(dataToUnderscore); | |
$('#contenedor').append(htmlElement); | |
}); | |
}).fail(function(jqXHR, textStatus) { | |
cosole.log( "error: ", textStatus ); | |
}).always(function() { | |
console.log( "complete" ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment