<div id="comments_box">
</div>在这个DIV 中 用Ajax调用一个评论的文件
 $('#goods_evaluation_title_box > a').click(function(){
                $('#goods_evaluation_title_box > a').removeClass("a_click");
                $(this).addClass("a_click");
                $.post("../comment/comment.php",{
                 gid:$('#gid').val(),
                 commentstype:$(this).attr("name")
                 },function(data){
                     $('#comments_box').html("");
                     $('#comments_box').html(data);
                 });                                                   
                 });
           
           $('all_comment').addClass("a_click");
           $.post("../comment/comment.php",{
                 gid:$('#gid').val(),
                 commentstype:"all_comment"
                 },function(data){
                     $('#comments_box').html("");
                     $('#comments_box').html(data);
                 });调用评论文件,然后传递参数给comment.php  但是我在comment.php里边做分页后 点击下一页时候 浏览器地址就变成comment.php?...(参数)   这个怎么解决啊

解决方案 »

  1.   

    $.post("../comment/comment.php",{用变量接收url,每次点击下一页的时候就重新组合url(但参数的,比如页数等),comment.php根据参数返回指定的数据
      

  2.   

    注意:下面的只是个大体流程,细节需要楼主自己根据数据库来做修改
    //ad.php页面if($_GET){
    echo rand();
    }else if($_POST){
    echo rand();
    }else{
    echo rand();
    }//test.html页面<div id="div">首页内容</div>
    <input type="button" name="button" value="myAjax" onclick="post_test()"><script language="javascript">
    var request;
    function createxmlHttpRequest(){//判断浏览器类型,创建xmlHttpRequest对象
    if(!request){
    if(window.XMLHttpRequest){
    request = new XMLHttpRequest();
    }else{
    request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    }
    }function get_test(){//get发送模式
    createxmlHttpRequest();
    var url = "ad.php";//?text=" + encodeURI("下一页内容");
    request.open("get", url, true);//同步或异步
    request.onreadystatechange = callback;
    request.send(null);
    }function post_test(){//post发送模式
    createxmlHttpRequest();
    var url = "ad.php";
    var send = null;//"text=" + encodeURI("下一页内容");
    request.open("post", url, true);//false同步 true异步(默认的)
    request.onreadystatechange = callback;
    request.setRequestHeader("content-type", "application/x-www-form-urlencoded");
    request.send(send);
    }function callback(){//回调函数
    if (request.readyState == 4){
    if (request.status == 200){
    document.getElementById("div").innerHTML = request.responseText;
    }else if(request.status == 404){
    alert("该路径未找到");
    }else if(request.status == 403){
    alert("禁止访问");
    }else{
    alert("status is " + request.status);
    }
    }
    }
    </script>