I have the following code to check if a username existes. In my IDE it crashes and in the Browsers, It shows the returned html for a second and the goes away, and the page goes back to the top. Since it does come back correctly , I know it is working on one level.
$("#addNew").submit(function (){
$("#UserExists").hide();
var text = $('#username').val();
var textlength = text.length;
if(textlength>2)
{
var name = $('#username').val();
var data = 'username='+name;
$.ajax({
type:"POST",
url:"CheckName.php",
data:data,
async: false,
success:function(html){
if(html=="That Username is already in use")
{
x=2;
$("#UserExists").show();
$("#UserExists").text(html);
}
}
});
}
if(x==2)
{
return false;