在我的 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/