I'm doing an ionic app in which I put the zip in a field and the backend returns all other data, such as state, city, street ... But something strange happens, it returns the entire structure of php and not the data that should come. I did a test application, on the web, that works, only on the ionic that is giving this problem.
The error in the console follows:
angular:
angular.module('app.controllers',[]).controller('enderecoCtrl',function($scope,$http){$scope.pegaCep=function(){//console.log($scope.endereco.cep);$http.get("php/pegaCep.php?cep="+$scope.endereco.cep).then(function (endereco){
console.log(endereco);
});
}
})
php:
<?php
include('correios.class.php');
$cep = $_GET['cep'];
if(isset($_GET['cep'])){
$correios = Correios::cep($_GET['cep']);
$correios = json_encode($correios[0]);
die($correios);
}elseif(isset($_GET['codigo_rastreio'])){
die(json_encode(Correios::rastreio($_GET['codigo_rastreio'])));
}else{
die('informe parametro GET cep ou codigo_rastreio');
}
?>
Print Console Network Tab: