$.ajax({
type: "get",
url: "test.jsp",
data: "name="+name,
success: function(msg) {
// msg is returned by the ajax function
// this holds the returned data
alert(msg);
// Compare the msg variable to see if it returned condition
// this compares the ENTIRE text of return, if it has any more
// characters in it, this condition will never be met!
if(msg == "available"){
alert("Yes!");
}else{
alert("No :-( "); // Sad face :( The return was something different
}
}
});