angularjs - angularjs 和 CI:预检响应无效(重定向)
问题描述
请帮助我通过这几天的尝试来学习 angularjs 中的基本 crud 操作我刚刚得到了显示表数据的输出(使用 $http.get)接下来我尝试执行删除但我得到了 CORS 错误。是的,但记录被成功删除。
我的代码点火器功能是这样的:
public function delete_user($user_id){
header('Content-Type: application/json;charset=UTF-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: DELETE, HEAD, GET, OPTIONS, POST,
PUT');
header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-
Disposition, Content-Description');
$this->users_model->delete_user($user_id);
redirect('Users/index');
}
angularjs中的控制器功能:
$scope.delete = function(id)
{
$http.delete('http://localhost/**/****/*****/users/delete_user/'+ id)
.then(function(response){
$scope.userList= response.data;
});
}
解决方案
推荐阅读
- php - 在 codeigniter 中重定向和加载视图
- powershell - 使用相对和绝对路径在powershell脚本中调用文件
- php - Bundle配置:默认填充数组节点
- mysql - 使用空值更新 COALESCE 查询
- swift - 在 Swift 中简化枚举关联值的运算符或函数
- python - python 3:py2app“未找到模块(无条件导入)”
- javascript - Odoo - 计算领域在本地而不是在线工作
- python - 对 groupby 函数应用过滤
- javascript - 如何从 AngularJS $http.get().then() 获得响应
- python - 在文件 Python 中的特定文本行中附加数据