$(function(){
$('a').click(
function(){
$.ajax({
type: "GET",
url:$(this).attr('href'), //取得a标签链接地址
beforeSend:function(){
$("#news").text("请稍等!");
},
success:function(data){
$('#news').html(data); //将数据重新加载到lcontent容器中
}
});
return false; //使a标签失效
})
})第二种function news(id){ //news函数名 一定要和action中的第三个参数一致上面有
var id = id;
$.get('{:U("Home/Index/index")}', {'p':id}, function(data){ //IndexAction中的用get方法发送信息到news方法,注意此处的链接
$("#news").replaceWith("<div id='news'>"+data+"</div>"); //news一定要和tpl中的一致
});
} 这两种我都试了,但为什么不是只加载div里面的数据呢,而是完整的<html>
<body>
...
</body>
</html>
为什么包括html,<head>..<./head>,body呢,怎么试都不行
只要div id='news'里面的数据
<div id='news'> <!--这里的news和上面js中的news要一致-->
<table>
<foreach item='v' name='list'>
<tr><td>{$v.id}</td><td>{$v.title}</td></tr>
</foreach>
</table>
{$page}
</div>网上代码无非就这两种,但都会出现这种情况 最佳答案