Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax Function Only Working Part of the Time
    text
    copied!<p>I am using the following Ajax function format:</p> <pre><code>var xmlhttp; function addAddress(str) { if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { //specific selection text document.getElementById('info').innerHTML = xmlhttp.responseText; } } var addAddress = "add"; xmlhttp.open("POST", "sys.php", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); var queryString = "&amp;addAddress=" + addAddress; xmlhttp.send(queryString); } function GetXmlHttpObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } if (windows.ActiveXObject) { return new ActiveXObject("Micorsoft.XMLHTTP"); } return null; } </code></pre> <p>Up until now, all of my Ajax functions, like the one above, have been running fine. However, now the function will work only sometimes. Now, sometimes I will have to click the onclick event a couple times to execute the function or the function will just hang, and then after about 4 minutes it will execute.</p> <p>I tested parts of the function and found that the issue lies some where at the:</p> <pre><code>if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { alert(xmlhttp.status); //specific selection text document.getElementById('info').innerHTML = xmlhttp.responseText; } </code></pre> <p>When the function works, I can alert(xmlhttp.status) and get 200. However, when it's not working, the alert box doesn't even trigger. In fact, nothing happens, not even an error.</p> <p>Could this be a server issue? I am kind of thinking my website got hacked, but I cannot find any issues accept that the Ajax functions are not executing properly.</p> <p>Lastly, I do not get this problem on my localhost, it's only happening on the live website.</p> <p>Any help will be greatly appreciated.</p> <p>Thanks</p>
 

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