I am getting this error :
XMLHttpRequest cannot load http://192.168.1.33:8080/ws/target. Origin null is not allowed by Access-Control-Allow-Origin.:1
When i am trying to load a html page on webview .I enter the script tag like that.
<script src="http://192.168.1.33:8080/target/target-script-min.js#anonymous"></script>
Actually This error ing when I am trying to debug my code on weinre . can you please tell how to remove this error ?
is there way to remove this error ? But when I make phonegap project and load same HTML with same import script line.
<script src="http://192.168.1.33:8080/target/target-script-min.js#anonymous"></script>
with this line
I am able to debug my file on winre.
can you please tell how i will remove this error when I load on webview ?
I am getting this error :
XMLHttpRequest cannot load http://192.168.1.33:8080/ws/target. Origin null is not allowed by Access-Control-Allow-Origin.:1
When i am trying to load a html page on webview .I enter the script tag like that.
<script src="http://192.168.1.33:8080/target/target-script-min.js#anonymous"></script>
Actually This error ing when I am trying to debug my code on weinre . can you please tell how to remove this error ?
is there way to remove this error ? But when I make phonegap project and load same HTML with same import script line.
<script src="http://192.168.1.33:8080/target/target-script-min.js#anonymous"></script>
with this line
I am able to debug my file on winre.
can you please tell how i will remove this error when I load on webview ?
Share Improve this question asked Aug 4, 2014 at 12:07 user3703527user3703527 3- Did you check this thread : stackoverflow./questions/11318703/… ? – mguimard Commented Aug 4, 2014 at 12:14
- You have to enable CORS in the web-service, and allow the client IP (or *) to Access-Control-Allow-Origin in the web-service. – Avishek Commented Aug 4, 2014 at 12:15
- what is does ? it solve my problem ?> – user3703527 Commented Aug 4, 2014 at 12:15
1 Answer
Reset to default 13The issue is occurring because of the CORS policy in your browser. In order to remove the error you normally have to make a change server side to whatever server you happen to be using. You'll have to add the header:
Access-Control-Allow-Origin: *
See here for more info on how to do this for specific back-end framework.
That said since your using cordova you can also override the browser's behavior like so:
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
wv.getSettings().setAllowUniversalAccessFromFileURLs(true);
}
if you are using a webview. If you don't want to mess with the webview directly you can also set
<access uri="*" subdomains="true" />
In your res/xml/cordova.xml
. See here for more details http://docs.phonegap./en/1.9.0/guide_whitelist_index.md.html