Php 使用上一个jquery移动页面中的参数更改ajax url
我正在使用JQM 1.0.1构建一个应用程序。我有一个查询,它向JSON输出一个城市列表,以及每个城市中特定类型商店的数量。我有几种店铺类型:机械、轮胎、油漆和车身等。我对每种店铺类型都有不同的查询。在我的移动应用程序的第一页上,我有一个不同商店类型的列表,在shoptype页面上,我使用ajax列出每个城市的城市和商店数量。我想通过在第一页上传递每个商店类型列表中的参数来更改ajax url。通过这种方式,我可以动态加载正确的查询,而不是为此加载多个页面 查询示例:Php 使用上一个jquery移动页面中的参数更改ajax url,php,jquery,ajax,jquery-mobile,Php,Jquery,Ajax,Jquery Mobile,我正在使用JQM 1.0.1构建一个应用程序。我有一个查询,它向JSON输出一个城市列表,以及每个城市中特定类型商店的数量。我有几种店铺类型:机械、轮胎、油漆和车身等。我对每种店铺类型都有不同的查询。在我的移动应用程序的第一页上,我有一个不同商店类型的列表,在shoptype页面上,我使用ajax列出每个城市的城市和商店数量。我想通过在第一页上传递每个商店类型列表中的参数来更改ajax url。通过这种方式,我可以动态加载正确的查询,而不是为此加载多个页面 查询示例: $query= "SELE
$query= "SELECT City, COUNT(ShopId) AS count FROM tabel WHERE Shoptype = 'D' and Visible = 1 Group By `City`";
第一页:
<div data-role="page" id="shopType" data-add-back-btn="true">
<div data-role="header" class="heading">
<h1></h1>
</div>
<div data-role="content">
<div class="choiceList">
<h1>Choose a shop type</h1>
</div>
<ul data-role="listview" class="mainmenu">
<li><a href="#shopType.html" id="diesel" data-transition="slide">Diesel Repair</a></li>
<li><a href="shopType.html" data-transition="slide">Mechanical</a></li>
<li><a href="shopType.html" data-transition="slide">Paint and Body</a></li>
<li><a href="shopType.html" data-transition="slide">Tires</a></li>
<li><a href="shopType.html" data-transition="slide">Transmission</a></li>
</ul>
</div>
<div data-role="footer">
<h4><script type="text/javascript">
var d = new Date();
document.write('<span class="copyright">© ' + d.getFullYear() + ' </span>');
</script> </h4>
</div>
选择一种商店类型
var d=新日期();
document.write(“)”+d.getFullYear()+”);
第二页(shopType.html)
jQuery(函数(){
$.ajax({
url:'includes/typeD.php',
processData:对,
数据:{},
数据类型:'json',
成功:函数(json){
$.each(json.shops,function(i,dat){
var count=dat.count;
var city=数据城市;
$(“#城市菜单”)。追加(“”);
});
$(“#城市菜单”).listview(“刷新”);
},
错误:函数(x,y,z){}
});
});
创建一个url
变量,并将其替换为静态url?提示:JQM 1.0太旧了,请升级到最新版本1.4.3
<div id="city" data-role="page" data-add-back-btn="true">
<div data-role="header"></div>
<div data-role="content">
<div class="choiceList">
<ul data-role="listview" id="cityMenu" class="mainmenu"></ul>
<script>
jQuery(function() {
$.ajax({
url: 'includes/typeD.php',
processData: true,
data:{},
dataType:'json',
success: function(json) {
$.each(json.shops, function(i, dat){
var count = dat.count;
var city = dat.City;
$("#cityMenu").append('<li><a href="#">' + city + '<span class="ui-li-count">' + count + '</span></a></li>');
});
$("#cityMenu").listview("refresh");
},
error: function(x,y,z) {}
});
});
</script>
</div>
</div>
</div>