Unable to make ajax call from web view in Windows 10 Cordova application

We are developing an application for Windows 10 cordon. In accordance with our requirement, we have added a web view ( <x-ms-webview id="id-web-view" height="100%" width="100%"></x-ms-webview> ) inside the HTML page and loaded the resources (HTML, JS, CSS, etc.) inside the web view from the AppData \ Local \ Packages \ LocalState directory. HTML, CSS, JS and other resources load perfectly.

We cannot make any AJX call from a web view (embedded page). Getting error - XMLHttpRequest: network error 0x80070005, access denied . AJAX call is very good for parent HTML.

This seems to be a CORS problem. I tried various jQuery and other options to enable CORS. He does not work.

Any help would be appreciated.

+6
source share
2 answers

To enable CORS, simply add the response header "Access-Control-Allow-Origin: {your domain} or {*}" to the website of your server side.

The steps for adding a response header depend on your server. You can access CORS on the server for most of the servers used.

Let me know if the server on your side is not on this list, or there are some other problems.

0
source

Configure 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 more information, see Go.microsoft.com/fwlink/?LinkID=617521 add the 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/

0
source

All Articles