0

次の ajax コードを使用してテストすると、安らかな Web サービスが実行され、動作しています。

$(document).on('pagebeforeshow','#page2',
    function(){
                $('#submit').click(function() 
                {
                    var name = $("#username").val();
                    var surname = $("#usersurname").val();

                    alert(name + " " + surname);

                    $.getJSON("http://localhost:8080/rest/index.php/api/practice/test/name/"+name+"/surname/"+surname + "/format/json",
                    function(data) 
                    { 
                        alert(data.result);
                    });
                });         
              });

このコードを使用して、同じ安らかな Web サービスにアクセスしますが、Android エミュレーターを使用します。PhoneGap を使用してエミュレータで使用したコードは次のとおりです。

$(document).on('pagebeforeshow','#page2',
    function(){
                $('#submit').click(function() 
                {
                    var name = $("#username").val();
                    var surname = $("#usersurname").val();

                    alert(name + " " + surname);

                    $.getJSON("http://10.0.2.2:8080/rest/index.php/api/practice/test/name/"+name+"/surname/"+surname + "/format/json",
                    function(data) 
                    { 
                        alert(data.result);
                    });
                });         
              });

また、次のように config.xml ファイルに変更を加えました。

<access origin="http://10.0.2.2/rest/index.php/api/practice/test" subdomains="true"/>

アプリはまだ機能していないようです。誰か助けてください

4

1 に答える 1

0

元の行がわからない...試しましたか:

<access origin="http://10.0.2.2:80080*" subdomains="true"/>

あるいは

<access origin="http://10.0.2.2*" subdomains="true"/>

?

于 2013-01-30T13:40:03.323 に答える