简体   繁体   English

无法从Windows 10 Cordova应用程序中的Web视图进行ajax调用

[英]Not able to make ajax call from a Web View in Windows 10 Cordova App

We are developing a Windows 10 cordova app. 我们正在开发Windows 10 cordova应用程序。 As per our requirement we have added a Web View ( <x-ms-webview id="id-web-view" height="100%" width="100%"></x-ms-webview> ) inside an HTML page and loading resources (HTML, JS, CSS etc) inside Web View from AppData\\Local\\Packages\\LocalState directory. 根据我们的要求,我们在一个网页内添加了一个Web视图( <x-ms-webview id="id-web-view" height="100%" width="100%"></x-ms-webview> )从AppData \\ Local \\ Packages \\ LocalState目录中的Web视图中的HTML页面和加载资源(HTML,JS,CSS等)。 HTML, CSS, JS and other resources are loading perfectly fine. HTML,CSS,JS和其他资源正在加载完美。

We are not able make any AJX call from web View (embedded page). 我们无法从Web View(嵌入页面)进行任何AJX调用。 Getting Error- XMLHttpRequest: Network Error 0x80070005, Access is denied . 获取错误 - XMLHttpRequest:网络错误0x80070005,访问被拒绝 AJAX calls are woring fine for parent HTML. 对于父HTML,AJAX调用很好。

Seems its a CORS issue. 似乎是一个CORS问题。 I have tried various JQuery and other option to enable CORS. 我已经尝试了各种JQuery和其他选项来启用CORS。 Its not working. 它不起作用。

Any kind of help will be appreciated. 任何形式的帮助将不胜感激。

Customize the content security policy in the meta tag http-equiv="Content-Security-Policy" as needed. 根据需要在元标记 http-equiv =“Content-Security-Policy”中自定义内容安全策略。 Add 'unsafe-inline' to default-src to enable inline JavaScript. 将“unsafe-inline”添加到default-src以启用内联JavaScript。 For details, see go.microsoft.com/fwlink/?LinkID=617521 add meta tag http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *" 有关详细信息,请参阅go.microsoft.com/fwlink/?LinkID=617521添加元标记http-equiv =“Content-Security-Policy”content =“default-src'self'数据:gap:ssl.gstatic.com'不安全-eval'; style-src'self''unsafe-inline'; media-src *“

Please visit http://taco.visualstudio.com/en-us/docs/cordova-security-whitlists/ 请访问http://taco.visualstudio.com/en-us/docs/cordova-security-whitlists/

To enable CORS, simply add the response header "Access-Control-Allow-Origin: {your domain} or {*}" to your server side's website. 要启用CORS,只需将响应标头“Access-Control-Allow-Origin:{your domain}或{*}”添加到服务器端的网站。

The steps of adding response header is dependent on your server. 添加响应标头的步骤取决于您的服务器。 You can refer to CORS on the server for most used servers. 您可以在服务器上参考最常用服务器的CORS

Let me know, if the server by your side isn't in that list, or some other specific problems appear. 让我知道,如果您身边的服务器不在该列表中,或者出现其他一些特定问题。

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

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