PhoneGap上的发布请求不起作用 [英] Post Request on PhoneGap does not work

查看:58
本文介绍了PhoneGap上的发布请求不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带AngularJS的PhoneGap构建Android应用程序.

I'm building an Android App using PhoneGap with AngularJS.

为了到达服务器端,我使用的是AngularJS的$ http服务

使用GET方法到达服务器端时,一切正常.

Evrything works fine when reaching the server side with GET methods.

使用POST后,请求似乎永远不会离开应用程序. 浏览器页面上的相同过程可以完美地工作.

Once using POST, it seems like the request never leaves de app. The same process on a browser page works perfectly.

这是我的POST请求

$http.post(URL_REQUEST,data,{'headers':{'Content-Type':'application/json' }})
.success(function(d, status, headers, config, statusText) {
    console.log("  success");

}).error(function(d, status, headers, config) {
    console.log("  error");
});

在我的logcat中,我将其作为错误结果:

And in my logcat i get this as a error result :

"status":403,
"config":{"method":"POST",
"transformRequest":[null],
"transformResponse":[null], 
... 

再次考虑浏览器上的evrything效果很好.在PhoneGap应用程序上,只有GET请求有效

Again on the broswer evrything works perfectly. On the PhoneGap App only GET request works

推荐答案

我从这篇文章中得到了它:

I got it from this post :

Cordova POST-请求禁止的403.未到达Dispatcher Servlet

在Web.xml文件上使用CORSFilter时,似乎像phonegap一样有问题.不知道为什么.但是一旦删除就可以了

Seems like phonegap have a problem when having CORSFilter on the Web.xml file. Dont know why. but once removed it works

这篇关于PhoneGap上的发布请求不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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