Ajax Call On Cordova Ios Securityerror: Dom Exception 18
Hi I'm building an iOS application via Cordova(5.1.1)/Phonegap and I have a problem I can´t solve. A basic Ajax call throws a SecurityError: DOM Exception 18 I tried all the trick
Solution 1:
Check your meta tag. By default, it uses:
<metahttp-equiv="Content-Security-Policy"content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
use the code below to enable all requests
<!-- Enable all requests, inline styles, and eval() --><metahttp-equiv="Content-Security-Policy"content="default-src *; style-src 'self' 'unsafe-inline'; script-src: 'self' 'unsafe-inline' 'unsafe-eval'">
Solution 2:
The above answer errors due to the syntax being incorrect.
Below is correct:
<metahttp-equiv="Content-Security-Policy"content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval';">
Solution 3:
Rather than allowing everything, you could just allow the urls that you are making the ajax call to. For example, if I wanted to get something from the facebook API, I could have something like:
<metahttp-equiv="Content-Security-Policy"content="style-src 'self' 'unsafe-inline'; script-src: 'self' https://graph.facebook.com">
Post a Comment for "Ajax Call On Cordova Ios Securityerror: Dom Exception 18"