android - AJAX call from local HTML file in WebvView -
i'm struggling simple ajax call working local html file loaded webview.
my jquery code:
$.ajax({ crossdomain: true, datatype: 'json', url: 'http://www.example.com', }).done(function(data) { // stuff here go through data }); and webview settings:
websettings websettings = webview.getsettings(); websettings.setappcacheenabled(false); websettings.setjavascriptenabled(true); websettings.setallowfileaccessfromfileurls(true); websettings.setallowuniversalaccessfromfileurls(true); websettings.setpluginstate(websettings.pluginstate.on); i had tried jsonp getting parse error, saying callback not called (this work fine on pc when loaded local file, inside chrome - callback working, android couldn't figure out?)
thanks in advance!
did tried set response header access-control-allow-origin: * in server script? in php set header before response:
header('access-control-allow-origin: *'); noting special has set in webview. opera sends options request before get or post, options request fails if there no above header entry, that's how works in desktop browser.
Comments
Post a Comment