search

Home  >  Q&A  >  body text

javascript - Why does Angular not use the error method when http request fails?

A 400 error is reported in the background. The error method I wrote is to alert a prompt, but there is no prompt. . what's the situation

大家讲道理大家讲道理2738 days ago901

reply all(4)I'll reply

  • 学习ing

    学习ing2017-06-20 10:08:06

    angular $http usage (.success, .error what happens?)

    $http({
      method: 'POST',
      data: {test: 'test'}
      url: '/someUrl'
    }).then(function(response) {
    
        // this callback will be called asynchronously
        // when the response is available
        
      }, function(response) {
    
        // called asynchronously if an error occurs
        // or server returns response with an error status.
        
      });

    reply
    0
  • 为情所困

    为情所困2017-06-20 10:08:06

    Is it because the backend did not respond to the AJAX request result and the frontend did not receive the status value

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-20 10:08:06

    It is estimated to be similar to the fetch API design. 400 is a normal code return. It can be executed to resolve

    reply
    0
  • 滿天的星座

    滿天的星座2017-06-20 10:08:06

    400 Bad Request
    The server cannot or will not handle the request due to obvious client error (e.g., malformed request syntax, too large size, invalid request message, or deceptively routed request).

    The above is taken from Wikipedia

    4** is about the front-end error. You should check whether the parameters and types sent match the definition of the back-end interface, and carefully look at the part that sends the request

    reply
    0
  • Cancelreply