Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript I';当我使用AngularJS运行$http POST请求时,我收到一个404错误_Javascript_Angularjs_Http_Post_Http Status Code 404 - Fatal编程技术网

Javascript I';当我使用AngularJS运行$http POST请求时,我收到一个404错误

Javascript I';当我使用AngularJS运行$http POST请求时,我收到一个404错误,javascript,angularjs,http,post,http-status-code-404,Javascript,Angularjs,Http,Post,Http Status Code 404,我正在开发一个应用程序,允许用户在投注池中下注。当用户点击一个按钮时,控制器中的一个功能被执行,但请求没有发出,并返回404错误,任何建议都将不胜感激 function placeBet(bet) { console.log('in place bet'); $http.post('https://colossusdevtest.herokuapp.com/api/tickets.json', { 'id': 550900, 'status': 'PLACED', 'custome

我正在开发一个应用程序,允许用户在投注池中下注。当用户点击一个按钮时,控制器中的一个功能被执行,但请求没有发出,并返回404错误,任何建议都将不胜感激

function placeBet(bet) {
console.log('in place bet');

$http.post('https://colossusdevtest.herokuapp.com/api/tickets.json', {
  'id': 550900,
  'status': 'PLACED',
  'customer_payout': '0.0',
  'stake': bet,
  'currency': 'GBP',
  'lines': 24,
  'amount_owned_customer': '1.0',
  'cost': '12.0',
  'created_at': '2015-07-23T17:00:10.000Z',
  'offer_amount': '0.0',
  'customer_winnings': '0.0',
  'offers_accepted': '0.0',
  'merchant_ref': '15ac9a2e-d4a8-4652-a60c-2b57d1afd92b',
  'pool': {
    'id': 171,
    'name': 'Mixed 4',
    'type_code': 'POINT_MARGIN',
    'headline_prize': '4996.06',
    'status': 'OPEN',
    'sched_start': '2015-07-28T11:00:00.000Z',
    'sched_next': '2015-07-28T11:00:00.000Z',
    'currency': 'GBP',
    'leg_num': 4,
    'sport_code': 'RUGBY',
    'has_offers': false
  }
}).then(() => {
  console.log('information posted');
});
}

$scope.placeBet = placeBet;

我看不到您的图像描述

你的电话回帖可能会有什么问题,几乎没有选择。 -如果你有正确的url-你用json完成的话听起来不太好 -确保您有正确的数据 -您可能需要http.post的配置部分。 -然后添加catch块以捕获错误 -检查是否是CORS问题


首先确保您可以使用chrome的Postman插件连接到服务器,然后将您的呼叫打包到http.post中

您是否尝试将代码更改为:

return $http({
  method: 'POST',
  url: '/someUrl',
  data: bet
}).then(function successCallback(response) {
    console.log(response);
}, function errorCallback(response) {
});

请确保您的请求不会跨域请求。

您确定可以发布吗?你是不是在向CORS提出请求?如果是,您的heroku应用程序是否设置为允许CORS请求?