Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy i can't auto run a JS function after ajax Retrieving function?
    primarykey
    data
    text
    <pre><code> &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#button1").click(function(){ if(document.getElementById("hidValid").value == "Correct Username &amp; Password"){ parent.result.location.href="user.php"; window.location.href="welcomeuser.php"; } }); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; function validate_use_pass(username,password){ var loginUserID = document.getElementById("loginUserID").value; var passUserID = document.getElementById("passUserID").value; if(loginUserID == ""){ alert("Invalid Username/Password."); }else if(passUserID == ""){ alert("Invalid Username/Password."); } if(loginUserID == "admin" &amp;&amp; passUserID =="admin" ){ parent.result.location.href="account.php"; window.location.href="welcome.php"; }else{ var xmlhttp; /*if(username.length==0 || password.length==0){ document.getElementById("validateText").value="Enter Username/Password"; return; }*/ if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("validateText").innerHTML=xmlhttp.responseText; document.getElementById("hidValid").value=xmlhttp.responseText; } } xmlhttp.open("GET","validateUsePass.php?username="+username+"&amp;password="+password ,true); xmlhttp.send(); } </code></pre> <p>}</p> <p>The problem is that I can't seem to run a function after the "xmlhttp.send();". because of this when I log in I need to press the button 2x to run the JS function.</p> <p>what happens is that the first press of the button will retrieve the data from the PHP then second one will run the JS function.</p>
    singulars
    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.
 

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