首页 > 解决方案 > 如何在 Angular JS 1.6.9 中将数据发布/更新到 PHP?

问题描述

我现有的项目在 Angular JS 1.5.7 上运行,所有功能都正常工作,但是当我将版本更改为 1.6.9 时,所有功能都停止工作,然后我不得不用 .then 替换 .success,但是,发布和更新功能不起作用。角度 JS 1.5

    $http.post(
        "insert.php", {
            'name': $scope.name,
            'email': $scope.email,
            'age': $scope.age,
            'buttonName': $scope.buttonName,
            'id': $scope.id
        }
    ).success(function (data) { //this function works on Angular JS 1.4.8
        alert(data);
        $scope.name = null;
        $scope.email = null;
        $scope.age = null;
        $scope.buttonName = "Insert";
        $scope.show_data();
    });
    //alert('Data inserted');
    $scope.IsVisible = $scope.IsVisible = true;
    $scope.response_msg = "Data Inserted";
}

我试图用 .then 替换 .success 没有用。PHP代码:

if(empty($info)){
}
else{
$emp_id=mysqli_real_escape_string($db,$info->id);
$emp_name=mysqli_real_escape_string($db,$info->name);
$emp_email=mysqli_real_escape_string($db,$info->email);
$emp_age=mysqli_real_escape_string($db,$info->age);
$button_name=$info->buttonName;

标签: phphtmlangularjs

解决方案


尝试在 then 函数之后添加 catch 函数并将 catch 函数中的错误打印到控制台。


推荐阅读