Ryan Vikander's Development Blog - PhoneGaphttp://blog.ryanvikander.com/index.cfm
Development blog that may contain but not limited to entries about Coldfusion, Javascript, Flex, and life. Maybe a splash of video games as well.en-usWed, 19 Dec 2018 05:05:31 -0600Wed, 28 Mar 2012 13:45:00 -0600BlogCFChttp://blogs.law.harvard.edu/tech/rssr.vikander@gmail.comr.vikander@gmail.comr.vikander@gmail.comnoReturning Dynamic Content In A PhoneGap Apphttp://blog.ryanvikander.com/index.cfm/2012/3/28/Returning-Dynamic-Content-In-A-PhoneGap-App
This is probably known to many but I was looking into this for fellow co-workers and I figured I would blog it so I don't forget it in the future. PhoneGap is great at making an HTML page into an mobile application. The thing with HTML is, it's static. You can't do direct database calls on load. Here is a quick solution I have found that seems to work. If other's have found a better solution, please post it.
index.html
<code>
<!doctype html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
<title>My App</title>
<script src="phonegap.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
$.ajax({
url:"http://www.ryanvikander.com/test.cfc?method=getdata",
success: function(data){
var content = $("#content");
content.html(data);
},
error: function(e){
console.log(e);
}
});
});
</script>
</head>
<body>
<div id="title_bar">Test</div>
This is a test
<div id="content"></div>
</body>
</html>
</code>
So really all I am doing is making a call to a cfc on load that returns some content and then adds that content to a div. Pretty simple.
ColdfusionPhoneGapWed, 28 Mar 2012 13:45:00 -0600http://blog.ryanvikander.com/index.cfm/2012/3/28/Returning-Dynamic-Content-In-A-PhoneGap-App