I'm trying to retrieve the data from my ajax request in json, they arrive correctly, but at the time I'm going to use them it only returns "undefined".
$("#selecionada").on("submit",function(){
var id_licaoselecionada = $("#prox").val();
console.log("ID da Licão selecionada = + "+id_licaoselecionada);
$.ajax({
url:'http://localhost/tempus/AJAX/licao/',
type:'POST',
data:{idlicao:id_licaoselecionada},
datatype:'json',
success:function(data){
console.log(data)
console.log("->"+data["nome"]);
$("#myModal").modal("hide");
$("#myModal2").modal("show");
$("#NomeDaLicao").html(data["nome"]);
$("#ImagemDaLicao").attr('src',data['icone']);
console.log('Licão escolhida');
},
error:function(){
console.log('Deu ruim, Lição nao carregada');
}
}) ;
return false;
Console returns like this:
- "id": "3", "0": "3", "name": "Today goes", "1": "Today goes", "icone": "assets / images / licoes / paper -plan-1.png "," 2 ":" assets / images / licoes / paper-plan-1.png "}
- - > undefined
- chosen license