PHP is not returning request data

0

I have 2 drop-downs. When a value is selected in the first, the second must list data for that value. However, my php, I think, is not getting the data sent. Can anyone help me?

Herearemycodes:

<bodyng-app="app" ng-controller="statecontroller">
<label>Categorias</label>
<select ng-model="contas.categoria">
    <option value="">Selecione</option>
    <option ng-repeat="x in categorias" value="{{ x.id_categoria }}">{{ x.categoria }}</option>
</select>

<label>Subcategorias</label>
<select ng-model="contas.subcategoria">
    <option value="">Selecione</option>
    <option ng-repeat="x in subcategorias" value="{{ x.id_subcategoria }}">{{ x.subcategoria }}</option>
</select>
</body>

<script src='js/angular.min.js'></script>
<script>
var app = angular.module("app",[]);
app.controller("statecontroller", ['$scope', '$http', function ($scope, $http) {

$http.get("php/carregaCategorias.php").success(function(response) {
    //console.log(response)
    $scope.categorias=response;
});

$scope.$watch('contas.categoria', function(newValue){
if(angular.isDefined(newValue)){
    $http.get('php/carregaSubCategorias.php?idCategoria=' + newValue).then(function(response){
        console.log(response)
    $scope.subcategorias = response.data;
  });
}
})


}]);
</script>

<?php
ini_set('display_errors', true);
error_reporting(E_ALL);

include_once("conexao.php");
$pdo = conectar();

header('Content-Type: application/json');

$postdata = json_decode(file_get_contents('php://input'));
$request = json_decode($postdata);
$idCategoria = $request->idCategoria;

$buscaCategoria=$pdo->prepare("SELECT * FROM sub_cat_entrada WHERE    id_categoria=:id_categoria ");
$buscarUsuario->bindValue(":id_categoria", $idCategoria);
$buscarUsuario->execute();

$return = array();

while ($linha=$buscarUsuario->fetch(PDO::FETCH_ASSOC)) {
    array_push($return, $linha);
}

echo json_encode($return);

?>
    
asked by anonymous 18.12.2015 / 23:19

0 answers