1
I have the following code:
script js.:
function maisDetalhes(id){
$.ajax({
url:'paginaDados.php',
type:'GET',
data:'id='+id,
dataType:'json',
success:function(data){
alert(data.id_event);
}
});
and in the pageDados.php:
foreach ($Dados as $Linhas) {
$resultado = array("id_evento" => $Linhas['id_event'],
"nome_evento" => $Linhas['event_name'] );
}
echo json_encode($resultado);
exit();
But in the ajax function sucess, I am not able to receive the data, when I give the Alert it shows 'Undefined', when I write only Alert(data) it appears everything, but I would like to take the data separately, as I can do?
Thank you very much in advance!
Putssss, thank you very much man, really, I am very lay with ajax, and I was breaking my head to try to solve this, thank you very much
– Gabriel Longatti
I suggest you use Firebug in Firefox, and instead of using Alert use console.log, because this way debuger tells you what type of variable is coming. It was a pleasure to help you.
– Pedro Soares