if thats the case try function checkIfUsername(o) { var bool; $.ajax({ type: "POST", url: ""+CI_ROOT+"index.php/admin/check_if_username", data: ({username: username.val()}), async: false, dataType: "json", success: function(data){ if(data.bool == true){ o.addClass('ui-state-error'); updateTips("Your username must be unique"); //return false; bool = false; } else{ //return true; bool = true; } } }); return bool; }
i am not very familiar with the case that async:false but from what you described, this should work