次の 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"/>
アプリはまだ機能していないようです。誰か助けてください