Javascript 使用jQuery刷新PHP不会';我不在IE工作
我想在javascript/jQuery中创建一个函数,它使用php脚本刷新我网站上的一些数据。我是这样使用它的:Javascript 使用jQuery刷新PHP不会';我不在IE工作,javascript,php,jquery,html,internet-explorer,Javascript,Php,Jquery,Html,Internet Explorer,我想在javascript/jQuery中创建一个函数,它使用php脚本刷新我网站上的一些数据。我是这样使用它的: function aval() { ... $("#dost").load("readadmin.php?date="+dzien+"&diff="+diff+"&dtyg="+d); setTimeout(aval,200); } <?php $diff=$_GET["diff"]; $name = $_GET["date"];
function aval()
{
...
$("#dost").load("readadmin.php?date="+dzien+"&diff="+diff+"&dtyg="+d);
setTimeout(aval,200);
}
<?php
$diff=$_GET["diff"];
$name = $_GET["date"];
$dtyg = $_GET["dtyg"];
$plik = fopen("myfile","r");
$tekst = fread($plik,filesize("myfile"));
fclose($plik);
$bookings = explode(";;;;", $tekst);
for ($i=0; $i<(sizeof($bookings)-1); $i++)
$data[$i] = explode(":::",$bookings[$i]);
echo "<script>";
// here I'm echoing some javascript code, that basically changes styles on my page,
//depending on my variables and data from a file
echo "</script>";
?>
<?php
session_start();
if(!session_is_registered('pass'))
header('location: login.php');
?>
...html code
其中#dost指我的站点末尾的某个div
然后,我的readadmin.php文件如下所示:
function aval()
{
...
$("#dost").load("readadmin.php?date="+dzien+"&diff="+diff+"&dtyg="+d);
setTimeout(aval,200);
}
<?php
$diff=$_GET["diff"];
$name = $_GET["date"];
$dtyg = $_GET["dtyg"];
$plik = fopen("myfile","r");
$tekst = fread($plik,filesize("myfile"));
fclose($plik);
$bookings = explode(";;;;", $tekst);
for ($i=0; $i<(sizeof($bookings)-1); $i++)
$data[$i] = explode(":::",$bookings[$i]);
echo "<script>";
// here I'm echoing some javascript code, that basically changes styles on my page,
//depending on my variables and data from a file
echo "</script>";
?>
<?php
session_start();
if(!session_is_registered('pass'))
header('location: login.php');
?>
...html code
您可以将时间戳添加到url,以便浏览器不会缓存文件:
$("#dost").load("readadmin.php?date="+dzien+"&diff="+diff+"&dtyg="+d+"&t="+Date.now());
不推荐使用会话_register()