0

My existing project ran on Angular JS 1.5.7, all the functionalities were working properly, but when I changed the version to 1.6.9, all the functionalities stopped working, then I had to replace the .success with .then, however, the post and update function isn't working. Angular 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";
}

I tried to replace the .success with .then didn't work. PHP code:

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;
georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • `$http`'s deprecated custom callback methods - `success()` and `error()` - have been removed. You can use the standard `then()`/`catch()` promise methods instead, **but note that the method signatures and return values are different.** – georgeawg Feb 21 '20 at 04:54

1 Answers1

0

Try add catch function after then function and print error in catch function to console.

Khaled Alam
  • 885
  • 7
  • 12