I’ve got a restful web service running and its working when I test it using the following ajax code:
$(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);
});
});
});
Now the I want to use this code to access the same restful web service but through the android emulator. Here is the code I have used in the emulator using 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);
});
});
});
I’ve also made changes to the config.xml file as follows:
<access origin="http://10.0.2.2/rest/index.php/api/practice/test" subdomains="true"/>
The app still doesn’t seem to be working. Please can someone help out
Not sure about the origin line… have you tried:
or even
?