title: jQuery ajax call fires error event on a 200 success call
body: <p>I have an ASP.NET Core WebAPI project with the following GET in my controller:</p>
  
  <pre><code>[HttpGet]
  public IEnumerable&lt;string&gt; Get()
  {
      return new string[] { "value1", "value2" };
  }
  </code></pre>
  
  <p>I'm trying to call this method from jQuery ajax call:</p>
  
  <pre><code>$.ajax({
      type: "GET",
      url: url,
      async: true,
      dataType: "json",
      success: function (data) {
          setJsonResult(data);
          showResultPane("API request result");
      },
      error: function (obj, textStatus, errorThrown) {
          setHtmlResult("Error returned by API: " + errorThrown);
          showResultPane("Unauthorized request result");
      },
      beforeSend: function (request) {
          if (currentToken) {
              request.setRequestHeader("Authorization", "Bearer " + currentToken);
          }
      }
  });
  </code></pre>
  
  <p>I monitor the web traffic with Fiddler and I see that the server returns a 200 Ok response with the following:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Transfer-Encoding: chunked
  Content-Type: application/json; charset=utf-8
  Server: Kestrel
  Access-Control-Allow-Origin: *
  X-Powered-By: ASP.NET
  Access-Control-Allow-Origin: *
  Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type,     Accept, Authorization
  Date: Thu, 08 Jun 2017 09:13:18 GMT
  
  13
  ["value1","value2"]
  0
  </code></pre>
  
  <p>The problem is that while the response from the web server is successful, the jQuery ajax error method is still being fired instead of the success method. I've tried playing with the <code>dataType</code> parameter (changing it, removing it) - no effect.</p>
  
  <p>I even tried returning a different value from the API that is just a string and even change <code>dataType</code> to <code>text</code> - still firing error.</p>
  
  <p>What's going on here?</p>