dongliao1949 2018-01-10 02:03
浏览 77

有时我得到一个空的响应,有时响应在angularjs中完美

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!!!!

  • 写回答

2条回答 默认 最新

  • duai4512 2018-01-11 18:12
    关注

    Re: Ñ is raplaced with �

    Search for 'black diamond' in Trouble with UTF-8 characters; what I see is not what I stored

    It says that either you did not start with utf-8 or that the connection was not made to declare that the client has utf-8 bytes. Ñ in latin1 is hex D1. In utf8, it is C391.

    评论

报告相同问题?

悬赏问题

  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码