I am developing a webpage in which I use Ajax in the following way.
var xmlhttpres="";
function Ajaxfun(spanUsername,spanPassword)
{
xmlhttpres=GetXmlHttpObject();
if (xmlhttpres==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="CheckExistuser.php";
url=url+"?Userid="+spanUsername;
url=url+"&NewPassword="+spanPassword;
xmlhttpres.onreadystatechange=Vad;
xmlhttpres.open("POST",url,false);
xmlhttpres.send(null);
//alert(url);
}
function Vad()
{
if (xmlhttpres.readyState==4)
{
var Result =xmlhttpres.responseText;
returnstr = Result.split('~');
if(returnstr[0]==5001) {
document.getElementById("Emailexists").style.visibility='visible';
Emailerrflg=1;
}
else {
document.getElementById("Emailexists").style.visibility='hidden';
Emailerrflg=0;
}
returnstr = Result.split('~');
if(returnstr[1]==1)
{
document.getElementById("Errormatchpwd").innerHTML='Username Already Exists';
document.getElementById("SRZUsername").select();
document.getElementById("SRZUsername").focus();
document.getElementById("Errormatchpwd").style.visibility='visible';
}
else
{
//alert("else part");
Econtd();
}
}
}
This works fine in Internet Explorer. But the function Vad()
does not get called in Firefox nor in Chrome. After displaying the error message, the page was refreshed. How can this problem be fixed?