Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) Programming AJAX AJAX Callbacks

Noah Fields
Noah Fields
13,985 Points

What if we get a status of 304(Not Modified)?

On an earlier step, instead of getting the normal 200(OK) response, I was given a 304(Not Modified) response, indicating that nothing had changed since the last time I requested the information. This is because I refreshed the page and requested the information a second time - since nothing had changed, the client (my browser) was redirected to its stored cache version and displayed that instead, which is presumably faster and more efficient for the network than sending the exact same data twice (far more so if the information sent was larger or more complicated than a short message).

Technically, though, even though everything is "okay" by any reasonable measure, the response code is not a 200, so the instruction to only load the content if the status code is 200 would fail. For that matter, there are other cases where the information is present, but elsewhere, so other 300 codes could also occur. Wouldn't it be within our best interest to keep these other codes in mind so that a simple redirect won't disrupt the request?

1 Answer

Kevin Gates
Kevin Gates
15,052 Points

I know this is a long-overdue response, but in short you don't see those 3xx response codes described because this course is meant to be introductory and not exhaustive. Since these lessons are just now being introduced to some people, it is helpful to keep in simple, then build on the concepts latter. You could in fact create a statement that says if the response is (200 || 3__) then do the desired function.