android - phonegap android ajax 请求适用于 GET 但不适用于 POST

标签 android ajax post cordova

在我的 phonegapp-ed android 应用程序中发送以下请求适用于 GET 但不适用于 POST。 使用 GET,一切正常。使用 POST,请求通过但 POST 变量 在服务器端没有通过,服务器返回 json 响应显示“未提供任何参数”。

POST 在我们的移动应用程序中运行良好 - 它只是我们遇到问题的 phonegap 应用程序。我在这里错过了什么???在此先感谢您提供的任何帮助!

我已经尝试更改 $.ajax 调用的设置、android list 以及我能想到的所有内容。

此外,我使用的是 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 有效。

关于android - phonegap android ajax 请求适用于 GET 但不适用于 POST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7762621/

相关文章:

wcf - Widdle服务的POST方法在Fiddler中失败

php - 如何在 html 页面上显示从 android 应用程序发送到 php 的数据?

android - PlayStore 中不兼容的 Android 应用程序

java - 无法连接到 python 服务器(android [java] 客户端)

ajax - 将 Prop 值传递给 axios 中的 url 不起作用

jquery - 防止隐形表单被轻易黑客入侵

jquery - 如果在 ASP.NET MVC 中不使用 cassini 进行 jQuery 帖子,则无法成功发布

Android:使用 RealViewSwitcher 像主屏幕一样在 View 之间切换

jquery - 通过 jQuery 发布数组

ajax - 使用 ajax 调用 prestashop 模块