PhoneGap的Andr​​oid的Ajax请求工作,但还是没有POST [英] phonegap android ajax requests work for GET but not POST

查看:77
本文介绍了PhoneGap的Andr​​oid的Ajax请求工作,但还是没有POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发送下面的请求,我phonegapp-ED Android应用程序适用于GET而不是POST。 随着GET,一切正常。随着后,该请求通过,但POST变量 没有在服务器端来通过,和服务器返回 JSON响应,上面写着'没有参数提供的。

开机自检工作正常,从我们的移动应用程序 - 它仅仅是PhoneGap的应用程序,在那里我们有一个问题。我在想什么在这里???在此先感谢您的帮助,您可以提供!

我试过在$就号召,Android清单,所有我能想到的更改设置。

另外,我使用的是Android 2.2和1.0的PhoneGap


 函数goTeam(){
    VAR dataString = {纬度:currentLocation.lat(),液化天然气:currentLocation.lng()}; //这一切工作
    $阿贾克斯({
            网址:http://example.com/request/goTeam,
            数据:dataString,
            数据类型:JSON,
            成功:
                    功能(二){
                            如果(b.status == 1){//宇豪!有用
                            } 其他 {
                                    //请求经历,但什么是错的 - 这就是我得到与POST
                            }
                    },
            类型:'后',//使用GET工作,不与岗位工作
            错误:函数(jqXHR,textStatus,errorThrown){警报(NOOOO。); }
    });
 

解决方案

的PhoneGap并与GET和POST工作 - 跨域安全问题不适用。我们有一个奇特的错误我们code,这是由工作preventing它。 PhoneGap的是pretty的真棒!

Sending the below request in my phonegapp-ed android app works for GET but not POST. With GET, everything works. With POST, the request goes through but the POST variables are not coming through on the server side, and the server returns a json response that says 'no parameters supplied.'

POST works fine from our mobile app - it is just the phonegap app where we are having an issue. What am i missing here??? Thanks in advance for any help you can provide!

I've tried changing the settings on the $.ajax call, the android manifest, everything I can think of.

Also, i'm using Android 2.2 and 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."); } 
    }); 

解决方案

Phonegap does work with both GET and POST - cross-domain security issues do not apply. We had an idiosyncratic error our code that was preventing it from working. Phonegap is pretty awesome!

这篇关于PhoneGap的Andr​​oid的Ajax请求工作,但还是没有POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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