title: asp.net ashx handler: can't receive response
body: <p>Hello everyone and thanks for your time.
  Here is my javascript:</p>
  
  <pre><code>$('.sender').click(function (e) {       
      $.ajax({
          type: "POST",
          url: "fHandler.ashx",
          data: { firstName: 'stack', lastName: 'overflow' },
          // DO NOT SET CONTENT TYPE to json
          // contentType: "application/json; charset=utf-8", 
          // DataType needs to stay, otherwise the response object
          // will be treated as a single string
          dataType: "json",
          success: function (response) {
              alert('success');
          },
          error: function (response) {
              alert('error: ' + response);
              console.log('err: '+response);
          }
      });                    
  });
  </code></pre>
  
  <p>And here is the code in my <code>.ashx</code> handler:</p>
  
  <pre><code>public void ProcessRequest(HttpContext context)
  {
      context.Response.AppendHeader("Access-Control-Allow-Origin", "*");//to fix the allow origin problem
      context.Response.ContentType = "text/plain";
      string json = new StreamReader(context.Request.InputStream).ReadToEnd();
      context.Response.Write(json);
  }
  
  public bool IsReusable
  {
      get
      {
          return false;
      }
  }
  </code></pre>
  
  <p>While the click event is working, my <code>Ajax</code>request doesn't seem to get any response as the alert at success doesn't popup. I've debugged using the browser's network console and it return the expected response but it doesn't seem to reach the success function in the <code>JavaScript</code> code. Any insights or suggestions are welcome. Thanks.</p>