ajax 异步交互
<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>