
i m not able to compare string with the responseText value, though the value in the responsetext is of string type. login.jsp:
print("<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
var showdata;var d;
function fun(a,b){
//document.write(a);
//document.write(b);
xmlHttp=GetXmlHttpObject()
var url="process_login.jsp";
url=url+"?name="+a+"&pwd="+b;
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
showdata = xmlHttp.responseText;
//var xx=trim(showdata.toString());
d="done";
//document.write(showdata.toString());
//document.write(showdata.localeCompare(d));
if(showdata == "done") //something wrong here..
{
document.getElementById("msg").innerHTML= showdata
}else{document.getElementById("msg1").innerHTML= showdata}
}
}
function GetXmlHttpObject(){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e) {
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
</head>
<body>
<h2>Login</h2>
<table border="0">
<tr>
<td>username:
<td><input type="text" name="lnm" id="lnm"/>
</tr>
<tr>
<td>password:
<td><input type="text" name="lpwd" id="lpwd"/>
</tr>
</table>
<input type="button" name="bt" id="bt" onclick="fun(document.getElementById('lnm').value,document.getElementById('lpwd').value);" value="login"/>
<div id="msg"></div><br><br><br>
<font color="red"><div id="msg1"></div></font>
</body>