Array from result;
{"autor":"Testando","publication":"a"}{"autor":"Testando","publication":"a"}{"autor":"Testando","publication":"asa"}{"autor":"Testando","publication":"a"}
PHP;
header('Content-Type: application/json');
while ($rows = $stmt->fetch(PDO::FETCH_ASSOC)) {
$autor = $rows['Nome'];
$publication = $rows['publication'];
$my = array(
"autor"=>"$autor",
"publication"=>"$publication"
);
echo json_encode($my);
}
Javascript;
dataType: "json",
success: function (data) {
$(data).each(function(autor, pubication) {
alert(data.autor + " : " + data.publication)
});
}
My problem: jQuery no alert the data
I think the problem is because there is no comma between the results, because when there is only one result, he warns normally in the future want to make a .append in the data, but I can not simply alert data, can anyone help?
successfunction is not executed. And there is a typo in your JS:pubication