Thursday, December 11, 2008

Ajax In Javascript

function getUserDetail()
{

var sServerName = new String(document.location);
if (window.XMLHttpRequest) {
var XML = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
var XML = new ActiveXObject("Microsoft.XMLHTTP");
}

var URL = "CheckLoginAjax.aspx?UserName=" + document.getElementById('login2').value + "&Password=" + document.getElementById('pass').value;

Type = "Type=";
XML.open("POST", URL, false);

XML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
XML.send(Type);

var s = XML.responseText;

if (s == "I")
{
alert('Login Id does not exists.');

return false;
}
if (s == "IV")
{
alert('Your Account is deactive');
return false;
}
else if (s == "U")
{
window.location = "UserProfile.aspx";
return false;
}
else if (s == "F")
{
window.location = "FacultyProfile.aspx";
return false;
}
else if(s=="A")
{
getAdmin();
return false;
}
}

No comments: