$arr=array('success'=>"1",'text'=>$rand); echo json_encode($arr);
html/js里面接受json数据
$.ajax({ type:'POST',dataType:'JSON',url:'test2.PHP',timeout:80000,data:{user:'80'},success:function(response,textStatus){
var data = eval('('+response+')');
if(data.success=='1'){
$('#c').append('[有数据]'+data.text+'<br>');
}
}
});