js代码
<script type="text/javascript" src="jquery.js"></script>
<script>
$(function(){
window.setInterval(function(){
$.getJSON("json.php",{"code":"<?php echo $fundcode ?>","rand":Math.random()},function(data){
document.getElementById('ceshi').innerHTML = data.name+data.price;
});
},1000);
});
</script> <div id="ceshi"></div>
php代码
<?php $price = rand(10,100); echo "{
\"name\": \"铜\",
\"price\": \"".$price."\",
\"diff\": \"++146\",
\"diffRate\": \"++0.37%\",
\"jk\": \"39487\",
\"zk\": \"39445\",
\"zg\": \"39977\",
\"zd\": \"39127\",
\"class\": \"39591\"
}";
?>