在服务器上部署项目后,Angularjs http.delete无法正常工作

时间:2016-06-02 04:40:40

标签: php angularjs laravel-5.1

我正在开发一个Laravel5.1项目。虽然使用xampp http.delete处理localhost工作正常,但在远程服务器上托管项目后,此删除选项无效,但其他属性工作正常。 这是代码的一部分

$scope.removeSaleTemp = function(id) {
        $http.delete('api/saletemp/' + id).
        success(function(data, status, headers, config) {
            $http.get('api/saletemp').success(function(data) {
                    $scope.saletemp = data;
                    });
            });
    }

' API / saletemp /'去SaleTempApiController

public function destroy($id)
{
    SaleTemp::destroy($id);
}

查看部分:

<tr ng-repeat="newsaletemp in saletemp">
                                <td>@{{newsaletemp.item_id}}</td><td>@{{newsaletemp.item.item_name}}</td><td>@{{newsaletemp.item.selling_price | currency}}</td><td><input type="text" style="text-align:center" autocomplete="off" name="quantity" ng-change="updateSaleTemp(newsaletemp)" ng-model="newsaletemp.quantity" size="2"></td><td>@{{newsaletemp.item.selling_price * newsaletemp.quantity | currency}}</td><td><button class="btn btn-danger btn-xs" type="button" ng-click="removeSaleTemp(newsaletemp.id)"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button></td>
 </tr>

请注意,此代码在localhost(xampp)上运行正常,但在服务器中部署后失败。

2 个答案:

答案 0 :(得分:0)

可能是你打错了网址。我想您正在尝试致电www.example.com/api/saletemp/1。相反,您打电话给www.example.com/something/api/saletemp/1网址。要确保您使用了正确的网址$http.delete('/api/saletemp/' + id)

可能会有所帮助。

答案 1 :(得分:0)

谷歌很多并找到了解决方案。 只需要在根目录

中的.htaccess文件中添加以下权限
<Limit GET POST PUT DELETE HEAD OPTIONS>
    Order allow,deny
    Allow from all
</Limit>
<LimitExcept GET POST PUT DELETE HEAD OPTIONS>
   Order deny,allow
   Deny from all
</LimitExcept>
相关问题