React to 303 status code in jquery ( Prevent from redirecting) React to 303 status code in jquery ( Prevent from redirecting) ajax ajax

React to 303 status code in jquery ( Prevent from redirecting)


Responses in the 300 range are meant to be transparent. AFAIK, web browsers don't expose any of them to javascript. Thus, handling the 303 is not an option.

Have you tried setting the cache property to false in the ajaxSetup? It will append a timestamp to the request, preventing the browser from caching the response. You can also do that manually yourself. The browser should match the first request url to the 2nd response


You cannot stop the browser from following the 303 redirect. It sounds like that's not what you want, anyway. Whatever you would do in the browser to prevent the original request from being cached should work equally well for preventing the redirected 200 from being cached. That said, there is little you can do on the browser side other than using a unique URL for each request. This is done for you automatically by jQuery when you set cache: false.

$.ajax({  url: "example.html",  cache: false  }}).done(function( html ) {  $("#results").append(html);});


This is old post, but maybe someone will find this useful.

I have the same issue, and in my case the problem was in the method that was called out using the ajax. The problem was in the redirection that was set in the method. So, based on this, you can't use both ajax and redirect(server side), and i removed redirect() function from method, i everything works as expected. Btw, i am using codeigniter.