mardi 11 juillet 2017

Angularjs laravel 5 posting form data using post method 404 page not found error. But get method works

Using Angularjs laravel 5.1 posting form data using post method 404 error comes but get method works fine

controller

`(function (ng, app) { app.controller('app.promocodeCtrl', function($scope,$http) { // create a message to display in our view

    $scope.newPromocode = function(){


        $scope.onSubmit = function(){
            console.log($scope.form);
            // $http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
            //$http.defaults.headers.post["Content-Type"] = "text/plain";
            var request = $http({
                method: "POST",
                url: "backend/statistics/promo",
                data: {
                    promocode : $scope.form.codetxt,
                    discount : $scope.form.discount,
                    minvalue : $scope.form.minvalue
                },
                headers: {'Content-Type': 'application/x-www-form-urlencoded'}
            }).success(function (data) {
                alert(data);
            });
        }

    };

});

})(angular, angular.module('app'));`

route

Route::post('statistics/promo', ['uses' => 'Api\Backend\Statistics@promoCode']);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire