title: Why does a POST response of 204 (no content) trigger the Angularjs error function?
body: <p>I have an Angularjs application that uses <code>$http.post()</code> to make web service calls.  The method it calls has a <code>void</code> return type, and it generates a 204 (no content) response code.  This goes into the error function that is defined in the <code>.then()</code> callback, and prints "no element found" in the log.</p>
  
  <p>If I return anything from the method, it returns the normal 200 response code.</p>
  
  <p><strong>Why is a success code triggering the error function?</strong></p>
  
  <p>Code as requested:</p>
  
  <pre><code>function myFn(inputData) {
      var d = { data: inputData };
      $http.post("../api/my/serverFn", d)
          .then(
              function(response) {
                  $rootScope.AddMsg("Success");
              },
              function(response) {
                   // The 204 response goes here.
                   $rootScope.AddMsg("Error");
              });
  }
  </code></pre>
  
  <p>The requested screenshot:
  <a href="https://i.stack.imgur.com/I1QFN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I1QFN.png" alt="enter image description here"></a></p>