无法在Android浏览器中使用AngularJS执行POST请求 [英] Can't perform POST request in Android browser with AngularJS

查看:397
本文介绍了无法在Android浏览器中使用AngularJS执行POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示记录的角度应用程序,并为用户提供添加记录的功能。

I've got a angular application that displays records, and gives the user the ability to add records.

一切在桌面或iOS设备上都很完美,但在安卓设备,POST方法失败(403 - 禁止)。

Everything works perfect on desktop or iOS devices, but on android devices, the POST method fails(403 - forbidden).

这是我服务中的代码:

obj.getRecords = function() {
    return $http.get(serviceBase + 'records');
};
obj.getRecord = function(id) {
    return $http.get(serviceBase + 'record/' + id);
};
obj.saveRecord = function(record) {
    return $http.post(serviceBase + 'record', record);
};

有遇到此问题的人吗?

推荐答案

$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";

可能会解决您的问题。

参考: Angular docs

这篇关于无法在Android浏览器中使用AngularJS执行POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆