我有两个setInterval(myFunction,40000)
和setInterval(myFunction2,50000)
其中myFunction的和myFunction2正在AJAX请求和怪异的行为,如果用户没有登录与重定向如果用户没有登录
echo '<meta http-equiv="refresh" content="0;url='.$home.'" />';
echo '<script type="text/javascript"> self.location = "'.$home.'"; </script>';
exit();
在阿贾克斯respons有:
<meta http-equiv="refresh" content="0;url=http://site.com/login" />
<script type="text/javascript"> self.location = "http://site.com/login"; </script>
但页面没有改变,并且在6个请求正在改变之后。
AJAX的
$.ajax({
type:"POST",
url:"http://site.com/thing.php",
data:submitData,
dataType:"html",
success:function(data){someDiv.html(data);}
});
在thing.php
<?php
if(is_logged()){
-- the code
}
else {
-- the redirect code
}
?>
?>
而且代码的工作,但在6请求
请向我们展示'yourFunction'和'yourFunction2'。你为什么在ajax响应中提供html? – Bergi
,因为我只想登录的用户使用它 – grape1
您已经写过。你如何获得ajax脚本中的html?你如何以及何时开始ajax请求?我们需要代码来帮助你。 – Bergi