cordova - PhoneGap 2.9.0 Loading External Scripts -
preface: i'm using coffeescript , haml , testing on android phone using phonegap build.
i attempting load external script being compiled on server phonegap app. when testing page locally works when testing on actual device doesn't seem getting script. have tried loading script in index.html:
%script{:type => 'text/javascript', :src => "http://192.168.5.112:3000/assets/mobile.js"}
i have tried using jquery's getscript, get, , ajax calls:
$.getscript('http://192.168.5.112:3000/assets/mobile.js', alert('success')) $.get 'http://192.168.5.112:3000/assets/mobile.js', (data) -> alert 'success server' + data $.ajax 'http://192.168.5.112:3000/assets/mobile.js', error: (jqxhr, textstatus, errorthrown) -> alert('localerror: ' + jqxhr + textstatus + errorthrown) success: (data, textstatus, jqxhr) -> alert('localsuccess: ' + data + textstatus + jqxhr)
all of give me successful alert still isn't loading script. have whitelisted server in config.xml
<access origin="http://192.168.5.112:3000" subdomains="true" />
still no luck. using weinre best of ability debug issue either script doesn't show @ in network panel or shown there no content.
any ideas appreciated!
192.168 local-host ip. when run on pc looking on pc file. when run on phone looking on phone file. not work. download js file , include in project. if include in project under /js folder include in head tag of html follows:
<script src="js/myscript.js"></script>
no need whitelist domains or anything.
if js file publicly accessible (ie: anyone, not you, can access via http://) can use:
<script src="http://www.serverwherethescriptis.com/myscript.js"></script>
attempting download script (example 2) can have other issues though. example, lets user wants use app doesn't have internet connectivity. app puke on itself. if have connectivity, increases load time of app. better have larger app because included js library have slower/inoperable app.
Comments
Post a Comment