Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

We are developing a Windows 10 cordova app. 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. HTML, CSS, JS and other resources are loading perfectly fine.

We are not able make any AJX call from web View (embedded page). Getting Error- XMLHttpRequest: Network Error 0x80070005, Access is denied. AJAX calls are woring fine for parent HTML.

Seems its a CORS issue. I have tried various JQuery and other option to enable CORS. Its not working.

Any kind of help will be appreciated.

like image 265
Shamse Alam Avatar asked May 10 '16 09:05

Shamse Alam


1 Answers

Customize the content security policy in the meta tag http-equiv="Content-Security-Policy" as needed. Add 'unsafe-inline' to default-src to enable inline 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 *"

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

like image 69
Maruthi Gongadi Avatar answered Sep 23 '22 14:09

Maruthi Gongadi