How to check Isavailablity in ajax?

Posted by udaya on Stack Overflow See other posts from Stack Overflow or by udaya
Published on 2010-05-08T10:24:00Z Indexed on 2010/05/08 10:28 UTC
Read the original article Hit count: 161

Filed under:
|

Hi This is what i have in my view page

<td width=""><input type="text" name="txtUserName" id="txtUserName" /></td>
<td><input type="button" name="CheckUsername" id="CheckUsername" value="Check Availablity" 
            onclick="Check_User_Name();"/></td>

Onclick of the button the Check_User_Name function in my ajax.js loads This is the Check_User_Name function

 function Check_User_Name(source)
{

    var UserName = document.getElementById('txtUserName').value;
    if(window.ActiveXObject)
    User_Name = new ActiveXObject("Microsoft.XMLHTTP");
    else if(window.XMLHttpRequest)
    User_Name = new XMLHttpRequest();
    var URL = newURL+"ssit/system/application/views/ssitAjax.php";
    URL = URL +"?CheckUsername="+UserName;
    User_Name.onreadystatechange = User_Name_Fun;   
    User_Name.open("GET",URL,true);
    User_Name.send(null);

}
function User_Name_Fun()
{
    document.getElementById('User_div').innerHTML=User_Name.responseText;
}

Then I can have the value in echo username then the $result has all the user name Hows can i checkIsavailablity of username from here if(($_GET['CheckUsername']!="") || (isset($_GET['CheckUsername']))) {

        echo $UserName = $_GET['CheckUsername'];//echo username
        $_SESSION['state'] = $State;
        $queryres = "SELECT dUser_name FROM tbl_login
                    WHERE dIsDelete='0'";
        $result = mysql_query($queryres,$cn) or die("Selection Query Failed !!!");

© Stack Overflow or respective owner

Related posts about php

Related posts about AJAX