0
I am performing a simple data return in a Jquery function. However, the error message is displayed. Follows code
JSON:
<?php
header('Content-Type: application/json');
$dados = "Meus Dados";
echo json_encode($dados, JSON_PRETTY_PRINT);
?>
Jquery:
function carregarJson(){
$.ajax({
url: "json.php",
dataType: 'json',
success: function(data){
alert(data);
},
error:function(){
alert("erro");
}
});
}
What an error message?
– rray
only that "error" Alert is displayed
– user50409
Of the one
console.log(data)
inerror:function ...
– rray
Try this format:
header('Content-Type:' . "text/plain");
– Ivan Ferrer