【问题标题】:Angularjs Http POST Request is going as OPTIONS for different domain ajax requestAngularjs Http POST 请求将作为不同域 ajax 请求的选项
【发布时间】:2015-08-19 17:06:44
【问题描述】:

我有 Angular js 中的项目。我想向特定的 url 发出 ajax 请求。 我用了两种方法。

$http.post(url, {
    params: {
        email: $scope.login.username,password:$scope.login.password
    }
})
.success(function(data, status, headers, config) {
  console.log('Success' + data);
})
.error(function(data, status, headers, config) {
  console.log('Error Status : ' + status);
});

$http({
    url: url,
    method: 'POST',
    data: loginData 
})
.success(function(data, status) {
    $scope.errormassage = '';
    accessToken = data.token;    
})
.error(function(data, status) {
    //alert("::status:"+status);
});

两者都是 POST 请求,但是当我在控制台中看到请求时,它会显示请求类型 OPTIONS。

此帖子请求在POSTMAN Chrome 插件中运行良好。

请帮忙。

【问题讨论】:

标签: jquery ajax angularjs http-headers


【解决方案1】:

它可能会发送一个预请求 OPTIONS,目的是确定端点是否允许 POST。

【讨论】:

    猜你喜欢
    • 2017-08-24
    • 1970-01-01
    • 1970-01-01
    • 2016-12-28
    • 2014-04-28
    • 2012-04-15
    • 1970-01-01
    • 2019-10-11
    • 2017-06-29
    相关资源
    最近更新 更多