Javascript AngularJS删除函数REST HTTP://1.1500错误
我正在使用AngularJS通过RESTAPI删除一行。当我单击函数删除行的链接时,我得到一个内部服务器错误。我在问如何修复表单以使其删除该行Javascript AngularJS删除函数REST HTTP://1.1500错误,javascript,angularjs,rest,http,Javascript,Angularjs,Rest,Http,我正在使用AngularJS通过RESTAPI删除一行。当我单击函数删除行的链接时,我得到一个内部服务器错误。我在问如何修复表单以使其删除该行 //CONTROLLER to delete a specific item countryApp.controller('DeleteLocation', function($scope, $http, $routeParams, $location) { //get item info var id = $
//CONTROLLER to delete a specific item
countryApp.controller('DeleteLocation', function($scope, $http, $routeParams, $location) {
//get item info
var id = $routeParams.locid;
$scope.activePath = null;
$http.get('http://localhost/slimtest2/location/'+id).success(function(data) {
$scope.location= data;
});
//add more stuff here
$scope.pedelete = function(id) {
$http.delete('http://localhost/slimtest2/location/1/delete', id);
}
});
用于删除行的视图
<div ng-controller="DeleteLocation">
<div ng-repeat="l in location.location">
Are you sure you want to delete the location named: {{l.location_title }}
<a href="" ng-click="pedelete(l.location_id)"> Delete This</a>
</div>
</div>
确实要删除名为{{l.location\u title}的位置吗
当服务器端发生错误时,会发生内部服务器错误。请检查服务器端代码/配置是否正确 需要检查的几点:1.对于删除请求,您的请求方法类型是“get”还是“delete”?为此,您需要检查API所期望的方法类型。您可能想改用
$http.delete()
。2.检查浏览器控制台/网络。你看到错误了吗?如果是这样,请找出错误以解决问题。错误描述应该是API发送的内容
希望这有帮助。检查您正在使用的API。。您是否按要求发送url?请使用POSTMAN检查API。如果API工作正常,这意味着问题出在你的应用程序中。我确实测试了我的API,它工作正常。我在正文{“location_id”:“[要删除的项目数”}它工作得很好。尝试在Angular方面模拟它,但到目前为止它不起作用。我建议使用fiddler来获得准确的API响应和它返回的数据。您需要了解服务器错误500与服务器或您发送的请求有关,而不是直接与Angular有关。这是一种删除方法,我使用了REST C它在Mozilla开发浏览器上运行良好。您是否尝试:
$http.delete('http://localhost/slimtest2/location/“+id).成功(函数(数据){$scope.location=data;});