title: Android WebView + AJAX local files
body: <p>I have an android webview loading a website that I have locally in my assets. I've not built it myself, and I have very little control over the markup, js etc. </p>
  
  <p>Problem: Parts of the website use jquery $.ajax-gets to fetch HTML to display in a modal, and I think I've run into a cross-domain problem (if I test the site locally on my desktop I get same-origin-warnings, my origin is "null"), ie for some reason the local js can't ajax-get other local files in the assets folder because the underlying browser thinks these are from different origins. I've read whatever I can get my hands on concerning this, and nothing seems to make any difference. Not getting any errors or warnings in LogCat.</p>
  
  <p>This is running on a Nexus 7, files are located in the assets folder (<code>file:///android_asset</code>). Everything else works fine, but no luck with the ajax GETs.</p>
  
  <p>From the manifest:</p>
  
  <pre><code>&lt;uses-sdk
      android:minSdkVersion="16"
      android:targetSdkVersion="18" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  </code></pre>
  
  <p>Relevant webview code:</p>
  
  <pre><code>mWebView = (WebView) findViewById(R.id.webview);
  mWebView.setWebChromeClient(new WebChromeClient());
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.getSettings().setDomStorageEnabled(true);
  mWebView.getSettings().setLoadWithOverviewMode(true);
  mWebView.getSettings().setUseWideViewPort(true);
  mWebView.getSettings().setSupportMultipleWindows(true);
  mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
  mWebView.setHorizontalScrollBarEnabled(false);
  mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
  mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
  mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
  mWebView.addJavascriptInterface(this, "android");
  if (savedInstanceState != null) {  
      mWebView.restoreState(savedInstanceState);
  } else {          
      mWebView.loadUrl("file:///android_asset/site/index.html");
  }    
  </code></pre>
  
  <p>Here's the relevant js:</p>
  
  <pre><code>var load = function ( source, callback, dontShowLoader ) {
  if( !dontShowLoader ) {
      loading( 'show' );
  }
  $.ajax({
      url: source,
      type: 'GET',
      data: {
          campaign: true
      },
      success: function ( data ) {
          var $data = $(data);
          loading( 'hide' );
          $data.data( 'url', source );
          callback( $(data) );
      }
  });
  };
  </code></pre>
  
  <p>Am I missing something here? Is there truly no way to do ajax GETs over local file content? Note that I <em>only</em> have the local files to work with, normal use case is that the tablet is not connected to the internet when using the app, so any external calls are a no-go.</p>