[B]Hi!
I am trying to call a php page using AJAX and it fails. I tested this by writing
if(ajaxRequest.open(“GET”, “page.php?q=”+s, true) alert("Success
") ;
else alert(“fail”);
and I got the fail messege.
I am not an expert in AJAX, php is more my thing and was wondering if any of the brilliant people here will be able to find out what the problem is.
the PHP code works fine, i tested it regardless of the AJAX.
the code is as follows:[/B]
function validateZip(zip) {
if(zip == "ZIP CODE" || zip == "")
{
alert("Please insert a zip code");
}
zipCurrent=zip;
var ajaxRequest;
try {
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e) {
// Internet Explorer Browsers
try {
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.onreadystatechange = function () {
var resp;
if (ajaxRequest.readyState == 4&&ajaxRequest.status==200) {
resp = ajaxRequest.responseText;
if (resp == "1") {
$("#ziperr").html("1");
} else {
$("#ziperr").html("0");
}
zipCurrent = resp;
}
}
ajaxRequest.open("GET", "checkzipPnina.php?q="+zip, true);
ajaxRequest.send(null);
return;