Recuperar json em php
Estou tentando recuperar um valor em json para uma variável php e não estou conseguindo.
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script>
jQuery(document).ready(function(){
jQuery("button").click(function(){
jQuery.ajax({
url: "pagina.php", //URL de destino
dataType: "json", //Tipo de Retorno
success: function(json){ //Se ocorrer tudo certo
var msg = json;
//alert(msg);
}
});
});
});
</script>
<title>json</title>
</head>
<body>
<button>Clique aqui</button>
<?php
$json = file_get_contents('pagina.php');
$bla = json_decode($json, true);
var_dump($bla);
?>
</body>
</html>
pagina.php
<?php
$texto="Estou aqui";
echo json_encode($texto);
?>
O que falta?
Desde já agradeço.
Discussão (16)
Carregando comentários...