Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jquery

ajax

http

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

like image 204
kdt Avatar asked Nov 28 '11 13:11

kdt


2 Answers

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.

like image 161
Michael Stum Avatar answered Sep 29 '22 02:09

Michael Stum


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.

like image 21
Tim O'Brien Avatar answered Sep 29 '22 03:09

Tim O'Brien