phonegap android ajax请求为GET工作,而不是POST



在我的phonegapp-ed android应用程序中发送以下请求适用于GET但不适用POST。有了GET,一切都行得通。使用POST,请求只经过POST变量都没有通过服务器端,服务器返回aJson响应说'没有提供参数'。

POST从我们的移动应用程序工作良好-它只是phonegap应用程序,我们有一个问题。我在这里错过了什么?提前感谢您提供的任何帮助!

我已经尝试更改$的设置。ajax调用,android manifest,所有我能想到的。

另外,我使用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,但是只能使用GET。

Phonegap可以同时使用GET和POST -跨域安全问题不适用。我们的代码有一个特殊的错误,使它无法工作。Phonegap非常棒!

最新更新