页面上显示一排标题,标题是用ajax获取的,如果我想点击对应的标题去子页面调出对应ID的详细数据要怎么写,比如点击ID1的标题跳转到子页面就调出ID1的相关数据,ID2的标题跳转到子页面就调出ID2的相关数据
这是ajax:
<ul id="gllk" class="xianxi">
</ul>
<script>
var $gllk = $('#gllk');
$.ajax({
type:"post",
url:"http://hyjd.weandy.com/web/server/get_gonglv.php",
dataType:"json",
data:{id:1},
success:function (msg) {
var _aHtml ;
for(var i=0;i<msg.data.length;i++){
var _dataId = Number(msg.data[i]['id']);
var _dataTitle = msg.data[i]['name'];
var _aVal="" ;
_aVal = _dataTitle+lastword;
_aHtml +='<li><a href="#" title="'+_dataTitle+ '" data-id="'+_dataId+ '" >'+ _aVal + '</a></li>';
}
$gllk.append(_aHtml);
setTimeout(function(){$('#gllk li').click(function(){
var id =$(this).find('a').attr("data-id");
console.log(id)
window.location.href='#';
});},0);
}
})
</script>
ruibin
相关分类