php - 如何在 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;
解决方案
尝试在 then 函数之后添加 catch 函数并将 catch 函数中的错误打印到控制台。
推荐阅读
- java - 如何在 JSON 模式中定义枚举?
- android - Android Studio 未显示更新的 Flutter 应用
- ruby-on-rails - 在 Rails 5.2 上安装 Postgres gem 会抛出错误 - Gem::Ext::BuildError: ERROR: Failed to build gem native extension
- episerver - EpiServer - 限制哪些块可以放在哪些文件夹中
- caching - Laravel+Vue. 缓存问题(其实只是保留变量名)
- php - CSRF 表格 - 您可以更改令牌吗?
- python - 当使用 Group By 作为日期并计算该期间的事件时,Pandas 从星期日开始一周
- docker - 在 docker 容器中运行 dotnet test
- android - 禁用指纹传感器 - Android 模拟器
- scala - jar 版本问题或 scala 问题