this is my ajax obj function
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!

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;
}
}
}
return ajaxRequest;
}



and

this is my main function


function chkUsername()
{
verifyuname=1;
var illegalChars = /\W/;
var uname=document.getElementById("unamecom");
uname.innerHTML="Please wait..";
username=document.getElementById("uname").value;
if(username.length<4)
{
uname.innerHTML="<font color='red'>Too short</font>";
verifyuname=0;
return;
}
else if (illegalChars.test(username)) {
uname.innerHTML="<font color='red'>The username contains illegal characters.</font>";
verifyuname=0;
}
xmlHttp=null;
xmlHttp=ajaxFunction();
url="checkregis.php";
url=url+"?username=username";
xmlHttp.onreadystatechange=stateChangedchkUsername
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}