I am using the ajax method in conjunction with php, and I want to know how to get the return variable from the function called onreadstatechange.
The java function is called onsubmit, and then it calls a php script to check some things in my database and return true or false depending on the results.
This is where I run into problems, I want onsubmit = "return snappyajaxfunction ()" to return false or true based on php results.
My question is: how to get the result false or true from stateChanged function to become a return for snappyajax function.
I tried to do this for kicks: result = request.onreadystatechange = StateChanged with no luck.
I also tried to save the responseetxt for the global variable and then return the global variable to snappyajaxfunction with no luck.
snappyajaxfunction() { request.onreadystatechange=stateChanged; request.open("GET",url,true); request.send(null); return result; } function stateChanged() { if (request.readyState==4) { return request.responseText; } }
The purpose of this is a script - check the username / password entered by the user with the username / password stored in my database. If it does not match, it returns false, and the form will not be submitted if it submits the form and the user is delivered to the welcome page ...
javascript ajax
payling
source share