【发布时间】:2013-01-30 13:16:24
【问题描述】:
当我使用以下 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"/>
该应用程序似乎仍然无法运行。请有人帮忙
【问题讨论】:
-
不确定原产线...您是否尝试过:
<access origin="http://10.0.2.2:80080*" subdomains="true"/>,甚至<access origin="http://10.0.2.2*" subdomains="true"/>?该 URL 是否真的在该远程服务器上工作? -
这正是我所缺少的,感谢您的帮助!
标签: ajax cordova android-emulator