0

When I call the jQuery .ajax method, I receive a 302 status code. This is expected behaviour.

Unfortunately the parameters sent with the first are not resent when the redirect occurs. This causes my validator function on the server to fail.

My question is, is it possible to resend the request after the 302 status to the new URL with the old parameters?

user2810895
  • 1,284
  • 3
  • 19
  • 33
  • Check this: http://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call – ThunD3eR Sep 13 '16 at 10:40
  • Are you talking about a POST request? Then it is irrelevant that it is an AJAX request, the same would happen with an “normal” request as well. If you want to redirect a POST request, so that the browser does repeat it to the new address instead of switching to GET, then the correct HTTP status code to use would be 307 instead of 302. (You’d have to check on browser support though, and here specifically browser support in combination with AJAX.) – CBroe Sep 13 '16 at 10:46
  • Tanks for the explanation. I'm using a GET request. I already tried with the `statusCode` option in `$.ajax` but that does not work – user2810895 Sep 13 '16 at 12:01

1 Answers1

0

I solved it by changing my routes so that there is no redirect involved

user2810895
  • 1,284
  • 3
  • 19
  • 33