一直在新网站上工作,并遇到问题。从父ajax的父窗口调用javascript函数
我有我的主要页面,该页面加载脚本每一秒钟检查是否完成了一个后台进程(通常为20秒〜ISH)
上的AJAX装载机但是,一旦AJAX脚本执行(20秒后来)它仍然每秒刷新。
一旦ajax脚本完成了它的工作,我需要将父页面重定向到一个新的url。
我的Ajax代码:
<script type="text/javascript">
function myFunction()
{
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.getElementById("txtHint").innerHTML=ajaxRequest.responseText;
}
}
ajaxRequest.open("GET", "code/timer.php?file='.$file.'", true);
ajaxRequest.send(null);
}
</script>
<script type="text/javascript">
function forward(){
location.href=\'http://domain/newpage.html\';
}
function setTimer(){
set = setInterval("myFunction()", 1000);
}
</script>
在向前反斜杠();是因为我的代码是从PHP回显。
我已经尝试了一些代码,但应该工作(儿童AJAX元素)的主要原因之一是:
window.opener.forward();
将不胜感激的任何帮助,你们能提供...感谢
请定义'parent.page',你使用的是框架还是弹出窗口? –
即时消息不使用。只有一个页面(index.html)加载了ajax脚本,并显示结果。一旦ajax脚本满足条件,我不能停止父刷新页面(index.html)刷新ajax脚本 –