Start a new topic




If I'm in the (javascript-) context of the main 'webview', I am allowed to do ajax request to any server on the web. But if I use a htmlDrawable and set the URI to a local html file (=file in the assts folder) , this file is not allowed to do the request.

(ERROR MESSAGE: XMLHttpRequest cannot load Origin null is not allowed by Access-Control-Allow-Origin.)

Unfortunately I can't adjust the server to deliver CORS or JSONP. Is there a way to set a proberty on the htmlDrawable to allow the ajax requests? 


Hi Matthias,

The Access-Control-Allow-Origin error message indicates that you are trying to fetch content through AJAX that is coming from a different domain than you are currently on.

To fix this, there are two thing you can do:

1.) Allow the origin domain you are sending the AJAX request from in your server configuration (if you use Apache, you need to set this in your VirtualHost), or

2.) Make the original and the requested domains the same (i.e. host the HTML page you are loading under the same domain you are serving the AJAX requests from).

Access-Control-Allow-Origin errors secure the user from inappropriate JavaScript content from other domains, there is no workaround by setting a specific property client-side, as this would eventually make this security measure useless.


Login or Signup to post a comment