What HTTP status codes count as success in jQuery.ajax?

前端 未结 2 609
生来不讨喜
生来不讨喜 2020-12-02 22:12

The documentation doesn\'t seem to specify exactly what is meant by \'success\' in jQuery.ajax. Is it any 2xx code? Only 200?

相关标签:
2条回答
  • 2020-12-02 22:30

    You'll find this in the done callback. A success is any status greater than or equal to 200 and less than 300. A notmodified (304) is also viewed as a success.

    0 讨论(0)
  • 2020-12-02 22:42

    From the source code:

    if ( status >= 200 && status < 300 || status === 304 ) {
    

    So any 2xx and under special circumstances 304 as well. 304 has some extra handling though, check the source for more info.

    0 讨论(0)
提交回复
热议问题