ajax通过新闻id获取列表
<div class="index_main">
<div class="page_l">
<include file="Public:left" />
<div class="weixin_item">
<h3>官方信息</h3>
<div class="weixin_box">
<div class="weixin_img"><img src="__IMG__/ewm.jpg" style="width:112px;height;112px"></div>
<div class="weixin_cnt">
<h6>扫一扫 找萌妹</h6>
<p>龙妹妹助你一起畅游<br>
《龙》世界</p>
</div>
</div>
</div>
</div>
<div class="page_r">
<div class="lis_pos"><div class="cat_name"><h3>新闻中心</h3><span>NEWS</span></div><div class="cat_pos">您所在的位置:<a href="{:U('Index/index_index')}" target="_blank">首页</a> > <a href="/" target="_blank">新闻中心</a></div></div>
<div class="news_box">
<div class="news_tabs">
<ul>
<li><a data-id="40" target="_self">综合</a></li>
<li><a data-id="40" class="cur" target="_self">新闻</a></li>
<li><a data-id="41" target="_self">公告</a></li>
<li><a data-id="42" target="_self">媒体</a></li>
<li><a data-id="43" target="_self">活动</a></li>
</ul>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="news_list">
<ul>
<foreach name="list" item="lists">
<li><span class="datetime">{$lists.update_time|date="Y-m-d",###}</span><a href="{:U('News/content','id='.$lists['id'])}" target="_self">{$lists.title}</a></li>
</foreach>
</ul>
<div class="clear"></div>
<div class="list_page">
{$page}
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="index_bottom_txt"><img src="__IMG__/bottom_text.png"></div>
<div class="clear"></div>
<div class="bottom_wrap"></div>
</div>
<div class="clear"></div>
<include file="Public:foot" />
<script language="javascript">
$(function(){
$(".news_tabs li a").click(function(event){
event.preventDefault();
$(".news_tabs li a").removeClass('cur');
$(this).addClass('cur');
var id = $(this).attr("data-id");
$.ajax({
url:"{:U('News/activity')}",
type:"post",
data:"id="+id,
dataType:"json",
success:function(str){
if(str.status){
$('.news_list ul').empty();
$.each(str.info.list, function(index, val) {
$("<li><span class=\"datetime\">"+val.create_time+"</span><a href=\"/home/news/content/id/"+val.id+".html\" target=\"_self\">"+val.title+"</a></li>").appendTo('.news_list ul');
});
$('.list_page').html(str.info.page);
}
}
});
});
$(document).on("click",".list_page div a",function(event){
event.preventDefault();
var id = $(".news_tabs li a.cur").attr("data-id");
$.ajax({
url:$(this).prop("href"),
type:"post",
data:"id="+id,
dataType:"json",
success:function(str){
if(str.status){
$('.news_list ul').empty();
$.each(str.info.list, function(index, val) {
$("<li><span class=\"datetime\">"+val.create_time+"</span><a href=\"/home/news/content/id/"+val.id+".html\" target=\"_self\">"+val.title+"</a></li>").appendTo('.news_list ul');
});
$('.list_page').html(str.info.page);
}
}
});
});
})
</script>