4
I’m making an Ionic app in which I place the zip in a field and the backend returns me all other data such as state, city, street... But something strange happens, it returns the whole structure of php and not the data that should come. I made a test application, on the web, that works, only on Ionic that is giving this problem.
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:
Post the code of how you communicate with the backend
– DiegoAugusto
How’s your code? Put the
PHP
that returns these data.– Diego Souza
The file extension is . PHP?
– SCOFIELD
Apparently PHP was not executed, raw was sent from source.
– Fábio Paiva