【发布时间】:2015-03-04 22:11:11
【问题描述】:
我有以下代码在我的端点上进行“POST”,如下所示:
var response = $resource(serviceURL, {}, {
get: {
method: "POST",
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
transformRequest: function(obj) {
var str = [];
for(var p in obj) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
}
return str.join("&");
}
}
});
response.get({
grant_type : grantType,
client_id : clientId ,
client_secret: clientSecret,
username : username,
password : passwordValue
}, function(data) {
alert("Authenticated ...");
}, function(error) {
alert("Error");
});
此验证用户的代码在桌面浏览器中工作(在 Chrome 上测试),但它与我的 Cordova iOS 和 Android 项目的代码相同,但在设备/模拟器/模拟器上,它只执行失败方法。
我检查了 Cordova 的 config.xml 文件,这不是跨域问题(我在 config.xml 文件中有
我已经尝试解决这个问题几个小时,但仍然没有运气。
为什么它只在设备/模拟器/模拟器中失败,但在浏览器中有效???
【问题讨论】:
标签: android ios angularjs cordova post