首页 > 其他 > 详细

ajax 异步交互

时间:2014-07-07 11:34:40      阅读:176      评论:0      收藏:0      [点我收藏+]

<script>
    $(function(){
        $("#sub").click(function () {
            $.ajax({
                url: ‘CheckPvUv.php‘,
                data: {
                    act:‘login‘,
                    un:$("#un").val(),
                    pw:$("#pw").val()
                },
                type: "post",
                success: function(data){
                    if(data == 1){
                        $("#tab").hide();
                        $.ajax({
                            url: ‘CheckPvUv.php‘,
                            data: {
                                act:‘CheckPvUv‘
                            },
                            type: "post",
                            success: function(data){
                                var jsonobj=eval(‘(‘+data+‘)‘);
                                $.each(jsonobj.data,function(i,n){
                                    test="<tr><td>"+ n.pv+"</td><td>"+ n.uv+"</td></tr>";
                                });
                                test1="<tr><td>pv统计</td><td>uv统计</td></tr>";
                                $("#table1").html(test1+test);
                            },
                            error: function () {
                                alert("通讯失败了")
                            }

                        });

                    }
                },
                error: function () {
                    alert("通讯失败了")
                }

            });
        })
    })
</script>

ajax 异步交互,布布扣,bubuko.com

ajax 异步交互

原文:http://www.cnblogs.com/qisel/p/3820392.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!