如标题所示,当我按登录按钮使用ajax调用发送GET请求时,我在单独的android设备上从chrome的远程调试中收到此错误。但是,它可以在浏览器上正常工作。我已经更改了js文件中URL中的IP地址,使其指向我的公共IP。
我检查并遵循了建议的步骤,例如将Content-Security-Policy标头添加到index.html,还检查了cordova插件白名单,将allow-intent和allow-navigation添加到config.xml文件中,还添加了cordova.js脚本指向我的index.html文件的标题,但是错误仍然存在。
我对此并不陌生,因此我不确定是否还有其他因素可能导致此错误,例如必须启用域。这是错误的屏幕截图。请告诉我是否还有其他信息。
以下是代码:
index.html
<!DOCTYPE html>
<html>
<head>
<title>AGW</title>
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' http://PublicIPAddress/MP/applogin.php">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<!-- include css file here-->
<!-- include JavaScript file here-->
<script src="cordova.js"></script>
<script type= "text/javascript" src="js/jquery-3.1.1.js"></script>
<script type="text/javascript" src="js/validlogin.js"></script>
</head>
<body>
<div class="container">
<div class="main">
<form class="form" method="post" action="#">
<h2>AGW</h2><hr/>
<label>Email :</label>
<input type="text" name="email" id="email"> <br />
<br />
<label>Password :</label>
<input type="password" name="password" id="password"> <br />
</form><br />
<br />
<input type="submit" name="login" id="login" value="Login">
</form>
</div>
</div>
</body>
</html>
config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>AWG Rewards System</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="http://127.0.0.1/MP/*" />
<allow-intent href="http://PublicIPAddress//MP/*" />
<allow-navigation href="*" />
<allow-intent href="*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
最佳答案
问题在于config.xml中指定的允许意图配置
config.xml同时指定了通配符和基于IP的允许意图配置。更正此配置并提及正确的IP应该可以完成此工作。