B
Bruce A. Julseth
I'm new to AJAX and would appreciate some suggestions.
I want to use AJAX to search an existing database for information. If the
information exists, return true otherwise false. I am currently doing this
by submitting a php form and validating the data, then returning to then
reloading the client form with the true/false result. I have:
function validateStreet() {
var xmlhttp = getxmlhttp();
var serverPage = "validateStreet.php?street=";
var street = document.getElementById('Address').value;
serverPage += street;
xmlhttp.open("GET", serverPage);
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
result = xmlhttp.responseText;
alert(result);
}
}
xmlhttp.send(null);
return result;
}
In this code, "result" is correct when displayed by the alert, but result is
"undefined" when "returned."
How do I return the "xmlhttp.responseText" value?
Thank you.
Bruce
I want to use AJAX to search an existing database for information. If the
information exists, return true otherwise false. I am currently doing this
by submitting a php form and validating the data, then returning to then
reloading the client form with the true/false result. I have:
function validateStreet() {
var xmlhttp = getxmlhttp();
var serverPage = "validateStreet.php?street=";
var street = document.getElementById('Address').value;
serverPage += street;
xmlhttp.open("GET", serverPage);
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
result = xmlhttp.responseText;
alert(result);
}
}
xmlhttp.send(null);
return result;
}
In this code, "result" is correct when displayed by the alert, but result is
"undefined" when "returned."
How do I return the "xmlhttp.responseText" value?
Thank you.
Bruce