jquery - Android kitkat cross-domain ajax failing -
i have android app loads html file webview assets folder. javascript in file attempts ajax call retrieve data remote server. attempt succeeds on 4.1 device fails on 4.4 device.
relevant code in activity's oncreate:
mwebview = (webview)findviewbyid(r.id.webview); websettings websettings = mwebview.getsettings(); websettings.setjavascriptenabled(true); websettings.setallowfileaccess(true); websettings.setallowuniversalaccessfromfileurls(true); mwebview.loadurl("file:///android_asset/test.html");
and in head element of test.html (which contains no other javascript):
<script type="text/javascript" src="js/zepto.min.js"></script> <script type="text/javascript" > $(document).ready( function() { var url = 'http://google.com'; $.ajax( { type: 'get', url: url, success: function(dataastext) { $('#report').html("success"); }, error: function( xhr, type) { $('#report').html("error"); }); }); </script>
-- success on 4.2, error on 4.4.
according documentation, websettings.setallowuniversalaccessfromfileurls(true); supposed enable cross-domain call.
i'm using zepto; tried using jquery instead , same happened.
i understand webview changed in kitkat. there other security-related setting i'm missing?
thanks in advance help.
Comments
Post a Comment