Reputation: 2971
I may be going about this completely the wrong way, but I'm attempting to migrate a web-based application to an Android application with as minimal changes as possible.
I have set up my Android application to populate from an HTML page, which works fine in my original basic example.
However, when I try to add any JQuery functions, these fail.
I have the following code:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
alert('outside doc ready');
$(document).ready(function () {
alert('inside JQuery');
});
</script>
</head>
<body>Some text</body>
</html>
Rendered in a browser, I get both the alert messages. Rendered through the Android App on my Samsung Galaxy S3, I simply get the first 'outside doc ready' alert. I have previously included a JQuery Mobile link, but it made no difference and my understanding is that it is more a UI function set anyway.
Any help would be greatly appreciated. If any further information is required, please let me know and I'll edit the question.
Upvotes: 0
Views: 397
Reputation: 5769
To load jQuery externally, you have to add the internet permission to the Android Manifest.
Upvotes: 2
Reputation: 2971
I have got this working.
For reasons I hope someone can explain, JQuery was not being loaded. I manually saved the JQuery library and added it into the 'assets' folder alongside the test html page. I then simply modified the include line...
<script type="text/javascript" src="jquery.min.js"></script>
And the page started working.
I suspect there are some security limitations at play here, as including 3rd party or external Javascript files to an application running in a local context is probably a bit dodgy.
If you took the time to read, thank you.
Upvotes: 0