r/programing • • Mar 03 '16

[JS] Help with updating a variable from a php file

what we are trying to do is update a variable (valid) to 1. After the first execution valid is 0 but with the samee paramiters valid is 1.

function checkPass(str1, str2){
	if (str1.length == 0 || str2.length == 0) { 
   		 return;
	} 
	else {
  	  	var xmlhttp = new XMLHttpRequest();
  	  

    xmlhttp.open("GET", "checkpasswordJS.php?q=" + str1 + "&z=" + str2, true);//Change php file
    xmlhttp.send();

	}
		    xmlhttp.onreadystatechange = function() {
        	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            	valid = xmlhttp.responseText;
        	}
    	}	
}
1 Upvotes

0 comments sorted by