I'm performing a simple data return on a Jquery function. However, the error message is displayed. Follow 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");
}
});
}