return value after callback function Not Working
<p>I don't Know is below a valid question? or Just my stupidity. </p>

<pre><code> function IsSlaExists(department) {
     var flag = "";
     $.ajax({
         type: "POST",
         data: "Type=ISSLAEXISTS&amp;Department=" + encodeURI(escape(department)),
         url: "class-accessor.php",
         success: function (data) {
             //flag=data;  
             flag = "YES";
         }
     });
     return flag;
 }

 alert(IsSlaExists('department'));
</code></pre>

<p>i'm trying to return the value of <code>flag</code> but function returns blanks even if i set the value of flag maually. 
what i'm doing wrong?</p>
