我目前正在尝试向 jQuery Mobile 迈出第一步。所以我正在开发一个用于火车时刻表的应用程序。没什么太复杂的。
我输入了一些关于出发、到达、小时数等的信息。查询 url 看起来像这样:
现在查询示例
,如果您转到http://poucaterra.joaodias.me/app/index.html中的应用程序索引
(例如,尝试在应用程序中输入相同的值。出发时输入“coimbra”,到达时输入“aveiro”,日期输入“2012-08-25”,小时输入 20)
显示结果只是一个空白页,上面写着“未定义”。
那么,对我来说,传递返回的 JSON 值、读取它们并将它们发送到带有列表视图的另一个页面,从而显示搜索结果的最佳方式是什么?
请,如果不是要求太多,请向我展示我当前代码的示例。因为因为我在这方面采取了初步措施,所以我已经尝试通读其他代码,但我似乎无法弄清楚在哪里放置什么,何时,如何......叹息我真是个菜鸟在这!谢谢 :)
啊,差点忘了。这是HTML代码:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="pt"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="pt"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="pt"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="pt"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Pouca Terra</title>
<meta name="description" content="Pouca Terra - Train timetables">
<meta name="viewport" content="initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;" />
<!-- Apple Start Icon -->
<link rel="shortcut icon" href="favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon.png"/>
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-ipad.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-iphone4.png" />
<link rel="apple-touch-startup-image" href="apple-touch-startup-image.png" />
<!-- CSS -->
<link rel="stylesheet" href="assets/css/jquery.mobile-1.1.1.min.css" />
<link rel="stylesheet" type="text/css" href="assets/css/themes/poucaTerra.css"/>
<!-- Javascript -->
<script src="assets/js/lib/modernizr-2.5.3.min.js"></script>
</head>
<body>
<!--
****************************************************
***************** PAGE: 1 - SEARCH FORM PAGE *************
****************************************************
-->
<div data-role="page" id="search">
<!-- HEADER TOP BAR -->
<div data-theme="a" data-role="header" data-position="fixed">
<h4>Pouca Terra</h4>
</div>
<!-- END HEADER TOP BAR -->
<!-- CONTENT FORM -->
<div data-role="content" style="padding: 15px">
<form id="search-form" action="cp/getdata.php?" method="get">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="textinput1">
Departure
</label>
<input name="departure" id="textinput1" placeholder="Estação de Origem" value="" type="text" />
</fieldset>
</div>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="textinput2">
Arrival
</label>
<input name="arrival" id="textinput2" placeholder="Estação de Destino" value="" type="text" />
</fieldset>
</div>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="textinput3">
Date
</label>
<input name="day" id="textinput3" placeholder="Formato: aaaa-mm-dd" value="" type="date" />
</fieldset>
</div>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<label for="slider1">
Hour
</label>
<input type="range" name="hour" id="slider1" value="hour" min="0" max="24" data-highlight="true" data-track-theme="b" />
</fieldset>
</div>
<input type="submit" value="Submit" />
</form>
</div>
<!-- END CONTENT FORM -->
</div>
<!-- ***************** PAGE: 1 - END SEARCH FORM PAGE ************* -->
<!--
****************************************************
***************** PAGE: 2 - RESULTS TRAIN TIMETABLES *************
****************************************************
-->
<div data-role="page" id="results">
<!-- HEADER TOP BAR -->
<div data-theme="d" data-role="header">
<h4>Resultados</h4>
</div>
<!-- END HEADER TOP BAR -->
<!-- CONTENT FORM -->
<div data-role="content" style="padding: 15px">
<ul data-role="listview" data-theme="c" data-dividertheme="d" data-counttheme="e">
</ul>
</div>
<!-- END CONTENT FORM -->
</div>
<!-- ***************** PAGE: 2- END RESULTS TRAIN TIMETABLES ************* -->
<!-- *** Javascript at the bottom (for performance purposes) *** -->
<!-- Add to Home -->
<script type="text/javascript">
if ('standalone' in navigator && !navigator.standalone && (/iphone|ipod|ipad/gi).test(navigator.platform) && (/Safari/i).test(navigator.appVersion)) {
var addToHomeConfig = {
animationIn:'bubble', // Animation In
animationOut:'drop', // Animation Out
lifespan:30000, // The popup lives 30 seconds
expire:2, // The popup is shown only once every 2 minutes
touchIcon:true,
message:''
};
document.write('<link rel="stylesheet" href="assets/css/add2home.css">');
document.write('<script type="application/javascript" src="assets/js/lib/add2home.js"><\/s' + 'cript>');
}
</script>
<!--jquery-->
<script type="text/javascript" src="assets/js/lib/jquery-1.8.min.js"></script>
<!--jquery mobile-->
<script type="text/javascript" src="assets/js/lib/jquery-1.8.min.js"></script>
<script src="assets/js/lib/jquery.mobile-1.1.1.min.js"></script>
<!--bootstrap datepicker-->
<script type="text/javascript" src="assets/js/lib/bootstrap-datepicker.js"></script>
<!-- Application Javascript -->
<script type="text/javascript" src="assets/js/pages/index.js"></script>
</body>
</html>