Im working with mysql and php with angular this is the code for the posting data
app.controller('buscar', function ($scope, $http) {
$scope.postData = function () {
var request = $http({
method: "POST",
url: 'busqueda.php',
data: {
cedula:$scope.cedula
},
headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' }
}).then(function successCallback(response) {
$scope.datos = response.data;
console.log($scope.datos);
},function(response) {
$scope.error= response.statusText;
console.log($scope.error);
});
}
});
and my php is:
$sql1 = "(SELECT * FROM `presentadas` LEFT JOIN `desembolsos` ON presentadas.`CLI_IDENTIFICACION` = desembolsos.`IDENTIFICACION` WHERE presentadas.`CLI_IDENTIFICACION` = '".$cedula."')";
$result1 = $conn1->query($sql1);
if ($result1->num_rows > 0) {
while($row1 = $result1->fetch_assoc()) {
$datos1[]=$row1;
}
echo json_encode($datos1);
}else{
echo "No se encontraron datos en presentadas";
}
I'm posting one number called cedula which is the think I'm searching in the DB and it`s corresponding row, as I said, it works with some numbers listed in the DB but with others numbers it doesn't, looking in the chrome's developers console it shows nothing when I showing the response with console.log(). Image 1: here is when is failing, clicking in the console log record, it shows me error in line console.log($scope.datos) I guess it is not getting data
Image 2:Here is a working example showing the json response
I don't know why I'm getting this type of inconsistency. Help me please!!!!