title: javascript function for server side validation using wcf
body: <p>I am using a wcf service to authenticate a user. the service returns a true or false based on whether the username/password are valid/invalid. how do I pass the returned value to the javascript function to decide whether the authentication failed or passed. </p>
  
  <pre><code>       function AuthenticateUser(email, password, onSuccess, onFailed) 
       {
  
               var person = { "Email": $("#Email").val(), "Password": $("#Password").val() };
               req = $.ajax({
                   type: "POST",
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   data: JSON.stringify(person),
                   url: wsUrl + "/AuthenticateUser",
                   success: function ()
                    {
                       req = null;
                       onSuccess();
                   },
                   error: function (jqXHR, textStatus, errorThrown) {
                       if (textStatus != 'abort')
                           onFailed(errorThrown);
  </code></pre>