简体   繁体   English

Cordova应用程序在Android设备上运行时无法进行Ajax调用

[英]Cordova app fails to make ajax calls while running on android device

< meta http-equiv="Content-Security-Policy" content="default-src 'self' *.xyz.com data: gap: https://ssl.gstatic.com *.xyz.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *;connect-src *">

Please check the above Error message that I am getting in visual studio 2015 when running in device is : FAILED TO LOAD RESOURCE XYZ.COM but the app works fine on ripple browser. 请检查以上错误消息,我在设备中运行时进入Visual Studio 2015时出现以下消息:无法加载资源XYZ.COM,但该应用程序在波纹浏览器上工作正常。

is the issue related to csp? 问题与csp有关吗? if so how may I fix it? 如果可以,我该如何解决?

Through the meta tag you posted. 通过您发布的meta标签。 The Ajax call has been enabled in CSP (through directive "connect-src *"). Ajax调用已在CSP中启用(通过指令“ connect-src *”)。

Please first check if XYZ.COM is valid. 请首先检查XYZ.COM是否有效。 And try adding the http/https schema to the meta tag directive if you are loading resource from a remote host. 如果要从远程主机加载资源,请尝试将http / https模式添加到meta标签指令中。 ex: 例如:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' http://*.xyz.com ";...>

If none of the above works, If you are having cordova-plugin-whitelist, I would suggest you adding the following codes to config.xml under root element: 如果以上方法均无效,则如果您具有cordova-plugin-whitelist,建议您将以下代码添加到root元素下的config.xml中:

<access origin="http://*.XYZ.com" />
<allow-intent href="http://*.XYZ.com" />
<allow-navigation href="http://*.XYZ.com"/>

If still nothing works, Could you share a basic demo that can reproduce this problem? 如果仍然无法解决问题,您能否分享一个可以重现此问题的基本演示?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM