XHR in a local WebView: problem on iPhone, works in Simulator
I want to load some data via an AJAX GET from a local HTML file.
I can see the request being processed, the response ist sent to the client, but the success callback is never fired – on the iPhone that is.
I am creating a html file in the applicationDataDirectory, which should be treated as a local file, actually, to prevent any cross-domain issues.
Anyway, the following code works perfectly in Simulator, on the device the request is sent and a response is received, but the callback is never processed.
(the code has been reindented for legibility, the testhtml string is all in one line)
var contentArea = Ti.UI.createWebView({});
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,'index.html');
var testhtml = "<html>
<head>
<script src='app://Resources/html/js/jquery-1.4.2.min.js' type='text/javascript'></script>
<script type='text/javascript'>
function test() {
$.ajax({url: 'http://www.google.com',
success: function() { alert('data received'); }});
}
</script>
</head>
<body onload='test();'></body></html>";
f.write(testhtml);
contentArea.url = f.nativePath;
Has anybody got any ideas?