i am using for a username but due to something it is caching the results, if i place alerts between it returns me correct results but if i remove it just returns true if first time is true and so on
i did a change now to use return just after the status but i started getting undefined and that does make sense because i am returning nothing just coming out of the function
function checkUsername(username) {
var breturn = true;
alert(username);
$.ajax({
url : 'check.php',
type : 'POST',
data : {
'username' : username
},
beforeSend: function() {
$('#results').html('Checking for Username...')
},
dataType:'json',
success : function(data) {
$('#results').removeClass('success');
$('#results').removeClass('danger');
if($.trim(data.status) == 1) {
$('#results').removeClass('success').addClass('danger').html(data.message);
breturn = false;
return breturn;
} else if($.trim(data.status) == 0) {
$('#results').removeClass('danger').addClass('success').html(data.message);
breturn = true;
return breturn;
}
},
error : function(request,error) {
alert("Request: "+JSON.stringify(request));
breturn = false;
return breturn;
}
});
}