首页 > jquery网页培训班 > 网页制作jquery无刷新分页代码

网页制作jquery无刷新分页代码

发布-网页培训班 | 浏览量-

网页制作jquery无刷新分页代码

<script src="script/jquery-1.6.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var index = 0;
        $(document).ready(function () {
            $.post("page.asp", { name: index }, function (msg) {
             
                $("tr:gt(0)").remove();
                var artice = msg;

                for (var i = 0; i < 5; i++) {
               
                    $("table").append("<tr><td>" + artice[i]["ID"] + "</td><td>" + artice[i]["Writer"] + "</td><td>" + artice[i]["Title"] + "</td></tr>");
                
                }
            }, "json");
        });
        $(document).ready(function () {
            $("a").click(function () {
                if ($(this).html() == "下一页") {
                    index = index + 5;
                    if (index > 10) {
                        index = 10;
                    }
                }
                if ($(this).html() == "上一页") {
                    index = index - 5;
                    if (index < 0) {
                        index = 0;
                    }
                }
             //   alert(index);
                $.post("page.asp", { name: index }, function (msg) {
                 //   alert(msg[0]["ID"]);

                    $("tr:gt(0)").remove();
                    var artice = msg;

                    for (var i = 0; i < 5; i++) {
                        // alert("11");
                        $("table").append("<tr><td>" + artice[i]["ID"] + "</td><td>" + artice[i]["Writer"] + "</td><td>" + artice[i]["Title"] + "</td></tr>");
                        // $("table").append("<tr><td>1</td><td>2</td><td>3</td></tr>");
                    }
                }, "json");
            });
        });
    </script>

原文地址:http://www.35ui.cn/post/20110610236.html

标签jQuery教程jquery

上一条: js判断浏览器刷新与关闭的代码
下一条: 如何让IE6/IE7/IE8支持CSS3属性的脚本ie-css3.htc

或许你还对下面的文章感兴趣