大家帮我看看这段代码有什么问题,为什么ajax不能正常翻页?谢谢啊,本人第一次发贴index.htm<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" src="images/jquery-1.3.2.min.js" type="text/javascript"></script>
<script language="javascript" src="images/jqueryajax.js" type="text/javascript"></script>

<link href="images/style.css" rel="stylesheet" type="text/css" /> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>guest_book</title>
</head>
<body><div id="all">
<div id="wrapper">
<div id="main">
<h1>留言版</h1>
<span id="post_mess"><a href="http://www.duanjiandong.cn" title="椰岛驿站">回到首页</a> | <a href="#footer" title="发表留言">发表留言</a></span><br /><br />
<div class="pagebar">页数:4&nbsp;3个/页&nbsp; <b>[1]</b>  <a href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=2')">[2]</a>  <a href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=3')">[3]</a>  <a href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=4')">[4]</a>  <a title=下一页 href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=2')">[>]</a> ... <a title=最后一页 href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=4')">[4]</a> </div>
<!--[if !IE]><!-->  
<div id="loading"></div>
<!--<![endif]-->
  
       <div class="post">
<h3> |<a href="12" target="_blank">个人主页</a> |2009-03-04 18:31:42&nbsp;曰:</h3>
<div></div>
<div class="reply">
<strong>Reply:</strong>
</div>
</div>
  
       <div class="post">
<h3>ajax |<a href="11" target="_blank">个人主页</a> |2008-03-08 23:39:40&nbsp;曰:</h3>
<div>ajax test</div>
<div class="reply">
<strong>Reply:</strong>
</div>
</div>
  
       <div class="post">
<h3>零零碎碎 |<a href="10" target="_blank">个人主页</a> |2008-03-08 22:34:55&nbsp;曰:</h3>
<div>或者</div>
<div class="reply">
<strong>Reply:</strong>
</div>
</div>
<div class="pagebar">页数:4&nbsp;3个/页&nbsp; <b>[1]</b>  <a href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=2')">[2]</a>  <a href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=3')">[3]</a>  <a href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=4')">[4]</a>  <a title=下一页 href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=2')">[>]</a> ... <a title=最后一页 href="javascript:do_page('/JqueryAjaxGuestBook/index.php?do=index&p=4')">[4]</a> </div>
</div>
 
<div id="footer"><br />
<a href="http://validator.w3.org/check?uri=referer" target="_blank"><img src="images/w3chtm.gif" alt="Valid XHTML 1.0 Transitional" border="0"/></a>
<a href="http://validator.w3.org/check?uri=referer" target="_blank"><img src="images/w3css.gif" alt="Valid XHTML 1.0 Transitional" border="0"/></a>
Copyright 2008 breeze All Rights Reserved  
</div>
</div><!--end main-->
</div><!--end all-->
</body>
</html>
jqueryajax.js$(document).ready(function (){
do_page(url); 
});function do_page(url){ 
$.ajax({
url: url,
type: 'GET', 
dataType: 'html', 
timeout: 20000,
beforeSend: function(){
$('#loading').innerHTML = "<img src=\"images/ajax-loader.gif\" /> loading……"; 
$('#loading').show();
        },
success: function(data){
$('#all').innerHTML = data;
},
complete: function(){
$('#loading').hide(500);
},
error: function(){
alert('您所请求的页面不正常!');
}
}); 
}

解决方案 »

  1.   

    一般我分页的时候不喜欢用ajax……毕竟这个不是小规模数据的更新……
      

  2.   

    谢谢你的回复,你说的很有道理,我其实只是想通过这段代码学习jquery的ajax使用方法,
      

  3.   

    如果你说的“学习”是从头学习的话,那么分页显然太复杂了。我的主页里有一些jQuery的例子,你可以参考一下:http://www.rsywx.net/jquery/demos
      

  4.   

    URI给错了:http://www.rsywx.net/jquery/demos/index.html