I’m trying to develop a proof of concept where I use jQuery to load HTML content into a div. I’m using jQuery, jQueryMobile, and PhoneGap. I have a simple index.html with a single jQueryMobile page. I want to inject into the content div the results (HTML) of a call to my server. I’m testing this on an Android emulator. Here’s my code:
function onBodyLoad()
{
document.addEventListener("deviceready",onDeviceReady,false);
}
function onDeviceReady()
{
var url = "http://www.myserver.com/content/qwerty";
$("#applicationContainer").load(url);
}
<body onload = "onBodyLoad();">
<div data-role="page" id="page">
<div data-role="header">
<h1>My Content</h1>
</div>
<div id="applicationContainer" data-role="content">
</div>
</div>
</body>
This is not working. What am I doing wrong? I can load my android apk file into the emulator and open up the app, but I can’t load HTML into the content div. My concept is to create android and iphone mobile apps using phonegap to load html content into pages. What am I missing? Thanks for your time.
I found how to white-list an external server:
What is the state of whitelisting in phonegap 1.3.0?
Look for phonegap.xml (mine is in res folder – ~/res/xml/phonegap.xml) and add:
This allows all domains.
Hope this helps.