Difference between loadUrl and loadData with javascript
<p>I try to load in an Android webview a html page with an ajax post request.</p>

<p>When I load the webview with loadUrl, the javascript works fine, but when I try to load with loadData (I need it) I get an error : "<code>NETWORK_ERR: XMLHttpRequest Exception 101</code>". This error sounds like a access control origin problem.</p>

<p>The parseJsoup function replace some string in the html page with good strings. I check the data that I pass to loadData and the script part is not alterate.</p>

<p>My oncreate function :</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);        
    String html = parseJsoup("index.html");

    setContentView(R.layout.main);
    myBrowser = (WebView)findViewById(R.id.mybrowser);
    myBrowser.getSettings().setJavaScriptEnabled(true); 
    myBrowser.setWebViewClient(new MyWebViewClient());
    //myBrowser.loadUrl("file:///android_asset/index.html");            
    myBrowser.loadDataWithBaseURL("", html, "text/html", "utf-8", null);
}
</code></pre>

<p>And my javascript code :</p>

<pre><code>$.ajaxSetup({
  contentType: "application/json; charset=utf-8",
  datatype: "json",
  async: false,
});


$.ajax({
    type: "POST",
    url: "my url",
    data: 'my data',        
    success: function(data){
    // Do some action here with the data variable that contains the resulting message
      document.write("OK "+JSON.stringify(data));
      console.log(data);
    },
    error: function(data){
      document.write("KO "+JSON.stringify(data));
      console.log(data);
    }
});
</code></pre>

<p>Thanks</p>
