小编Mic*_*eda的帖子

Angular $ http发送get而不是post

$http.post(main+'/api/getcard/', $.param({number: $scope.searchcard}), {headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'} })
        .then(function (response) {
            if(response.data != 0)
            {
                $location.path('/redeem/'+response.data.id);
                console.log(response.data);
            }
        });
Run Code Online (Sandbox Code Playgroud)

当我使用此代码时,我的chrome发送:

Request URL:http://cards.mporeda.pl/branch/api/getcard
Request Method:GET
Status Code:405 Method Not Allowed
Run Code Online (Sandbox Code Playgroud)

但是当我在laravel服务localhost:8000上使用相同的代码时,我得到:

Request URL:http://localhost:8000/branch/api/getcard/
Request Method:POST
Status Code:200 OK
Run Code Online (Sandbox Code Playgroud)

我在请求中没有任何更多的$ http配置.在此请求之前我在控制台上没有错误,所以我问我的代码是否正常.我的服务器有什么问题吗?

javascript methods http laravel angularjs

2
推荐指数
1
解决办法
1019
查看次数

标签 统计

angularjs ×1

http ×1

javascript ×1

laravel ×1

methods ×1