Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Android Phonegap 3网络应用白名单不工作_Javascript_Android_Cordova_Jsonp - Fatal编程技术网

Javascript Android Phonegap 3网络应用白名单不工作

Javascript Android Phonegap 3网络应用白名单不工作,javascript,android,cordova,jsonp,Javascript,Android,Cordova,Jsonp,我有一个phonegap android应用程序正在尝试从外部服务器获取数据: 服务器是一个.NETWebAPI,通过JSONP使用通信。同样的代码/服务器在使用phonegap 2.7的iOS中工作。对于Android,我使用的是PhoneGap3.1。我已经仔细检查了URL,以确保它是正确的。我的config.xml文件中还有下面一行 <access origin="*" subdomains="true" /> javascript请求代码是 $.support.cors =

我有一个phonegap android应用程序正在尝试从外部服务器获取数据:

服务器是一个.NETWebAPI,通过JSONP使用通信。同样的代码/服务器在使用phonegap 2.7的iOS中工作。对于Android,我使用的是PhoneGap3.1。我已经仔细检查了URL,以确保它是正确的。我的config.xml文件中还有下面一行

<access origin="*" subdomains="true" />
javascript请求代码是

$.support.cors = true;
        $.mobile.allowCrossDomainPages = true;
        $.mobile.loading('show');

        // enableFrontPageButtons(1)
        enableButtons(0);
        console.log('about to get message types');
        try {
        $.ajax({
            //url: 'http://localhost:8956/api/messagetypeopt/' + SENDER_ID ,
            url: SERVER + '/api/messagetypeopt/' + SENDER_ID ,
            type: 'GET',
            dataType: 'jsonp',
            jsonp: 'callback',
            crossDomain: true,
            async:   false,
            success: function (data) {
                //alert('1');
                localStorage.setItem("rawMessageTypes", JSON.stringify(data.branches));
                Sender.updateBranchesData(data);
                Sender.updateSenderData(data);
                //alert('2');
                setupBranches(data.branches);
                setMessageTypesDB(data.branches); // store in local database.
                updateMessageTypes(data.branches);
                WriteMessageList( getMessageDataForBranch(JSON.parse(localStorage.getItem("rawMessageTypes"))));
                //alert('3');
                // save sender data and branch data
                enableButtons(1);
                //$('#libName').val(ConfigData.SENDER_NAME);
                changeTheBranch(CURRENT_BRANCH);
               // alert('4');
                //alert('Update Complete');
                $('messagetypepopuptext').text('Update Complete');
                $('messagetypepopup').popup();

            },
            statusCode: {
                500: function() {
                    alert("An incorrect request went to the server, check your UserID? ");
                    enableButtons(1);
                    $.mobile.changePage('#pageSetup', {changeHash: false});
                } ,
                400: function() {
                    alert("An incorrect request went to the server, check your UserID? ");
                    enableButtons(1);
                    $.mobile.changePage('#pageSetup', {changeHash: false});
                }
            },
            error: function (x, y, z) {
                //alert('There was an error getting data from the server');
                enableButtons(0);
                $.mobile.changePage('#pageSetup', {changeHash: false});
            },
            complete: function (a, b) {
                //alert('complete:' + a + '\n' + b);
               $.mobile.loading('hide');
            }
        });

我真的被困在这上面了,所以我真的需要一些帮助。谢谢:)

我和你在同一页。它在iOS7甚至安卓2.3虚拟机上都能完美工作,但在安卓4.0.3上却不能工作。我使用的是Phonegap 3.1

---编辑---

我有各种各样的白名单网站,我把它们放在不同的方式

<access origin="*://site.com" subdomains="true"/>
<access origin="*://site.com/*" subdomains="true"/>
<access origin="*://site.com/something/*" subdomains="true"/>
<access origin="https://site.com/" subdomains="true"/>

由于我使用的是AngularJS,我不知道如何在代码中帮助您,但有一次我使用jquery进行了测试,我没有您的支持CORS代码。我还添加了

<access origin="..." subdomains="true"/>

位于res/xml/config.xml上的config.xml上

<access origin="..." subdomains="true"/>