evgenyneu / js-evaluator-for-android

A library for running JavaScript in Android apps.
MIT License
485 stars 84 forks source link

XMLHttpRequest #15

Open AhmedGamal92 opened 9 years ago

AhmedGamal92 commented 9 years ago

Trying to make XMLHttpRequest from js and I'm getting Access-Control-Allow-Origin error, and changing the AllowUniversalAccessFromFileURLs didn't help.

Any Ideas ?

colibri11 commented 9 years ago

http://enable-cors.org/index.html

evgenyneu commented 9 years ago

Good catch. The javascript is evaluated in the web view, and I would think that all HTTP requests from it are blocked. Otherwise it would be pretty insecure. There may be a way to allow those requests to specified domains.

AhmedGamal92 commented 9 years ago

The "AllowUniversalAccessFromFileURLs" method in the webview should allow the requests, but tried it and not working.

At last I managed to do this by implementing a java method in the javascript interface to do the request.