我有一个Cordova应用程序,其中第一页是一个登录名,它向外部服务器发出Ajax请求。
我已经添加内容的策略 - 安全meta标签如下: <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src: 'self' 'unsafe-inline' 'unsafe-eval'>
登录功能被调用和访问,但$.ajax
功能似乎被完全忽略。
函数被调用之前,我有以下
<feature name="Whitelist">
<param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
</feature>
<access origin="*" subdomains="true" />
<allow-navigation href="*" />
<access origin="http://*.nutshellapps.co.uk" />
<allow-navigation href="http://*.nutshellapps.co.uk" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
我加入了上述所有的作为预防措施,我给自己定
$.support.cors = true;
在我3210文件。
nutshellapps.co.uk
子域是人们用他们的凭据登录的内容。所以我已将http://*.nutshellapps.co.uk
添加到访问原点。
我的元标记是否正确?
我有内联样式和js以及包含代码的css/js文件的混合。
这对我以前使用的Cordova(3.5.0)版本有效,但现在这导致了重大错误。如果我在浏览器上运行应用程序,它工作正常,所以我明显知道它的白名单插件/跨域问题。
其他人有这个问题吗?
我的Ajax调用下面
$.ajax({
url: serviceURL + "Json/Authentication/login",
type: "GET",
data: {'data':JSON.stringify(loginData)},
dataType: "jsonp",
crossDomain: true,
success: function(data) {
console.log(data);
},
error: function(jqXmlHttpRequest, textStatus, errorThrown) {
console.log('error');
});
谢谢生病明天检查一下,当我早上回到办公室时。博客文章帮助我更多地了解科尔多瓦5.3.3,所以谢谢! – Pooshonk
正确的我已经测试了这一点,没有运气,仍然无法正常工作。结果会是什么如果我为我的CSP标签添加了一个随机数? – Pooshonk
你看到什么错误?如果您在运行应用程序时将Chrome远程调试器附加到设备并从Chrome刷新页面,则可能会在JS控制台中看到与内容安全策略相关的有用错误。 –