Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax Timed Event Redirect
    primarykey
    data
    text
    <p>Im trying to setup a redirect for a chat script. If the chat goes unanswered after x amount of time the page will redirect. </p> <p>I posted a question here yesterday regarding the same thing, but at the time knowing little in regards to JS I was trying to mix php with js. I have changed tactics.</p> <p>Here is what I got thus far:</p> <pre><code>function opCheck() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support XMLHTTP!"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { opCheck(); // alert('working2'); } } opjoined = "newchattimer.php"; xmlhttp.open("GET",opjoined,true); xmlhttp.send(null); } function opResult() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support XMLHTTP!"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { //alert('state = 4'); var op = xmlhttp.responseText; } } ajaxurl = "ajaxfiles/opAnswer_12.txt"; xmlhttp.open("GET",ajaxurl,true); xmlhttp.send(null); } setTimeout(function() { opCheck(); opResult(); //alert(op); if (op == 'n') window.location.replace("chatnoop.php"); }, 3000); </code></pre> <p>It creates the text file properly but ultimately no redirect. I used the chrome deveolpers tool and no errors. I also tried to <code>alert(op);</code> to see if the result is being grabbed, but I get no alert.</p> <p>What is wrong with this code?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload