title: AJAX not success returning from asp.net server
body: <p>as practicing Ajax, I wrote a Ajax call that sends to a local asp.net Handler.ashx a Json with a username and password, and returns true if they are equal to "jhon" "123456", else false.
  I debugged the code, and I saw that the Handler.ashx receives the call, does the validation, and write to response, but the Ajax call not success.</p>
  
  <p>this the Ajax call:</p>
  
  <pre><code>$.ajax({
      url: '/Handler.ashx',
      dataType: 'json',
      data: {
          name: document.getElementById("username").value,
          password: document.getElementById("password").value
      },
  
      success: function (json) {
          alert(json.isvalid);
      },
      error: function (jqXHR, textStatus, errorThrown) {
          console.log(textStatus, errorThrown);
          alert(textStatus + "  " + errorThrown);
      }
  });
  alert("failed");
  </code></pre>
  
  <p>and this is the server side:</p>
  
  <pre><code>&lt;%@ WebHandler Language="C#" Class="Handler" %&gt;
  
  using System;
  using System.Web;
  
  public class Handler : IHttpHandler {
  
      public void ProcessRequest(HttpContext context)
      {
          Console.WriteLine("check");
          var name = context.Request["name"];
          var password = context.Request["password"];
  
          string response = IsValid(name, password) ? "true" : "false";
          context.Response.ContentType = "appliaction/text";
          context.Response.Write("{isvalid:'" + response + "'}");
      }
  
      private bool IsValid(string name, string password)
      {
          Console.WriteLine("isvalid");
          return (name == "jhon" &amp;&amp; password == "123456");
      }
  
      public bool IsReusable
      {
          get
          {
              return false;
          }
      }
  
  }
  </code></pre>
  
  <p>thanks!</p>