ajax - Returning redirect as response to XHR request -


what happens if browser receives redirect response ajax request?

what happens if browser receives redirect response ajax request?

if server sends redirect (aka 302 response plus location: header) redirect automatically followed browser. response second request (assuming isn't redirect) exposed program.

in fact, don't have ability detect whether 302 response has occurred. if 302 redirect leads 200, program acts identically if original request led directly 200.

this has been both experience , behavior called out in spec.

2016 update: time has passed, , news new fetch() api spec'd offer finer-grained control of how redirects handled, default behavior similar xhr. said, works fetch() implemented natively. polyfill versions of fetch()—which based on xhr—continue have xhr's limitations. fortunately, native browser support seems rounding out nicely.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -