目前有兩個文件,一個是index.html,另一個是code/index.php我想以api的形式,用js將code/index.php內的數值顯示到index.html內支持jq和ajax輪詢,但是不太會寫另附code/index.php代碼求詳細解答 <?php
$data=file("date.txt");
$ini=0;
$p= rand(10, 99);
if(count($data)){
$data=explode(",",$data[0]);
$now=date("Y-m-d H:i:s");
$second=floor((strtotime($now)-strtotime($data[0]))%86400);
$ini=$data[1];
if($second>=35){
$fp=fopen("date.txt","w");
$str=date("Y-m-d H:i:s").",".($data[1]+$p);
fputs($fp,$str);
$ini=$data[1]+$p;
}
}else{
$fp=fopen("date.txt","w");
$str=date("Y-m-d H:i:s").",".$ini;
fputs($fp,$str);
}
echo $ini;
?>
js如何調用php文件內顯示的數值到html?
心有法竹
2018-07-13 13:15:45