【发布时间】:2017-01-17 14:36:27
【问题描述】:
在我的 PhoneGap 应用中,我有这段代码来测试 AJAX REST 通信:
$( document ).ready(function() {
$("#test").click(function() {
alert("OK");
$.ajax({
type: "GET",
data: {},
url: "http://localhost:8080/test-notifier-web/RegisterServlet",
});
});
});
<div class="row col-centered">
<button type="submit" id="test">Submit</button>
</div>
在 Chrome 中执行此代码没问题,我可以登录控制台,一切正常。当我使用 cordova build android 构建 apk 并在我的 Genymotion 设备上对其进行测试时,我没有收到来自服务器的响应。有的时候,用Genymotion浏览器通过web测试是可以的。
我用这段代码创建了一个新的空白应用程序,它与 apk 配合得很好。谁能帮帮我?
这是我的 config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="it.paytas.mobile" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Paytas Mobile</name>
<description>
A blank PhoneGap app.
</description>
<author email="support@phonegap.com" href="http://phonegap.com">
PhoneGap Team
</author>
<content src="index.html" />
<access origin="*" />
<preference name="DisallowOverscroll" value="true" />
</widget>
【问题讨论】:
-
粘贴您的 config.xml 和 Content-Security-Policy
-
@Eric 发布了 config.xml,我在哪里可以找到 Content-Security-Policy?