在我的phonegapp-ed android应用程序中发送以下请求适用于GET,但不适用于POST。
有了 GET,一切就正常了。使用 POST,请求会通过,但 POST 变量
服务器端未通过,服务器返回
json 响应显示“未提供参数。”
POST 在我们的移动应用程序中工作正常 - 这只是我们遇到问题的phonegap 应用程序。我在这里缺少什么???预先感谢您提供的任何帮助!
我尝试过更改 $.ajax 调用、android 清单以及我能想到的所有设置。
另外,我正在使用 Android 2.2 和 Phonegap 1.0
function goTeam(){
var dataString={lat:currentLocation.lat(),lng:currentLocation.lng()}; // this all works
$.ajax({
url: 'http://example.com/request/goTeam',
data: dataString,
dataType: 'json',
success:
function(b) {
if(b.status==1){ // woo hoo! it works
} else {
// the request went through but something was wrong - this is what i'm getting with POST
}
},
type: 'post', // works with GET, doesn't work with POST
error: function(jqXHR, textStatus, errorThrown){ alert("Noooo."); }
});
您是否尝试跨域请求?只有 GET 请求才以这种方式工作。您可以使用JSONP http://en.wikipedia.org/wiki/JSONP对于这种请求,但只有 GET 有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)