0
$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);
}
});
当我使用此代码我的铬发送:
Request URL:http://cards.mporeda.pl/branch/api/getcard
Request Method:GET
Status Code:405 Method Not Allowed
但是,当我在laravel使用相同的代码本地主机服务:8000我得到:
Request URL:http://localhost:8000/branch/api/getcard/
Request Method:POST
Status Code:200 OK
我没有任何更多$ http配置,只有请求中的这个头部选项。在请求之前,我在控制台上没有错误,所以我认为我的代码是可以的。我的服务器有什么问题吗?
当您使用'POST'时,您应该使用'data'而不是'param' –