我正在开发一个使用 json 检索数据库数据的移动应用程序。使用我的 mac 浏览器,我可以获得请求的数据和警报并将其显示在新的移动页面上。我无法让它在 ipad 或 iPhone 上的 safari 上运行。页面加载但没有数据。
任何提示将不胜感激。
HTML 代码
<!DOCTYPE HTML>
<html>
<head>
<title>tourmap_main.jpg</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script src="js/treedetails14.js"></script><div data-role="page" id="firstpage" data-theme="a">
<div data-role="header" data-position="fixed">
<h1>Winter Hill Garden Tour</h1>
</div>
<div data-role="content" id="mainpage" data-theme="a">
<div id="area1Button"><a href="#area1" data-role="button" data- transition="flip">AREA 1</a>
</div>
</div>
<div data-role="footer" data-theme="a" data-position="fixed"></div>
</div>
<div data-role="page" id="area1" data-add-back-btn="true" data-theme="a">
<div data-role="header" data-position="fixed">
<h1>Garden Tour - Area 1</h1>
</div>
<div id="area1content" data-role="content">
<div id="tree105" class="treebutton"><a href="#detailsPage" data-rel="page" data-role="button" data-transition="slide" data-id="27" class="treelink">Button 1</a>
</div>
<div id="tree106" class="treebutton"><a href="#detailsPage" data-rel="page" data-role="button" data-transition="slide" data-id="32" class="treelink">Button 2</a>
</div>
</div>
</div>
<div data-role="page" id="detailsPage" data-overlay-theme="a">
<div data-role="header" data-add-back-btn="true">
<h1 align="left"><span>Tree information -</span> <span id="treetitle"></span></h1>
</div>
<div id="treeDetails" data-role="content">
<div id="treedescription"></div>
</div>
<div data-role="footer" data-theme="a" data-position="fixed"></div>
</div>
还有我的脚本:
$(document).on('pagebeforeshow', '#firstpage', function(){
$('.treelink').live('click', function(){
var serviceURL = "http://winterhill.com.au/gardentour/services/";
currentId = $(this).attr('data-id');
$.getJSON(serviceURL + 'gettree.php?id='+currentId, function(data) {
var tree = data.item;
alert(tree.tree_description);
$('#detailsPage').append("<p>item1="+tree.tree_description +"</p>");
});
});
});
这是基本的代码设置:http: //jsfiddle.net/VgxnQ/1/