title: calling server side method in JQuery in asp.net
body: <p>in my application  i have  an  form    where  user enter  their username  first . now i should check  whether  that username is avilable  or not i have  wtitten an  method "username"  which does this  whuch  return  true  or false  as  a  return  type.
  here i am  doing  using  jQuery  with  ajax  to achive this  concept.
  once the user enter this name  and  when   he  goes   for the second   textbox  to type  this  code should  get executed  and  give  him the  result  as  a  pop up[moda popup] . if return value  is  true   from  method  "username"  from  user name  is  already in use  need  to display message "username  alredy in use"
  if return value is false "no need  to  display"</p>
  
  <p>right  now  my  code looks like this </p>
  
  <pre><code>&lt;head&gt;
    &lt;title&gt;Calling an ASP.NET Page Method with jQuery&lt;/title&gt;
    &lt;script type="text/javascript" src="jquery-1.2.6.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
        $(document).ready(function() {    
            $.ajax({    
                type: "POST",    
                url: "Default.aspx/Username",    
                contentType: "application/json; charset=utf-8",    
                data: "{}",    
                dataType: "json",    
                success: OnSuccess,    
                error: OnFailure    
            });    
      });
  
        function OnSuccess(result) 
        {
           // so  here i need   to  check  whethere  true  or false
           // based on that i need   to  show  modal  pop  up
            alert("Success!");    
        }
  
        function OnFailure (result)    
        {
            alert("The call to the page method failed.");    
        }    
    &lt;/script&gt;    
  &lt;/head&gt;
  </code></pre>
  
  <p>any  solution on this  would be great 
  thank  you</p>