ajax post form and then get 303 redirection

By : Nero_X
Source: Stackoverflow.com
Question!

It's originally a JSP form page, do post under same domain:

<form action="/dataHandler" method="post" enctype="multipart/form-data">

after the data post finished browser will get a 303 see other code. do the redirection to a different domain.

Now I need to use JavaScript to do the post. It's been posted successfully but in the redirection, it get a 500 Server Error.

Compare to the Original get. It seems missing the Cookie, Cache-Control, Content-Encoding, Content-Type, X-FRAME-OPTIONS fields and have a additional origin, Set-Cookie fields.

But i found out JS can't touch the redirection on this page, so how should I deal with the Error?

By : Nero_X


Answers
a related topic: React to 303 status code in jquery

It seems that JavaScript can't touch redirection. The 500 error is caused by those missing cookies. And I can't touch both that external server sending error and the redirection process. I have to re-config the server being posted to send back 200 code with an embedded redirection URL in the head. Then it's just simple JavaScript redirection.

By : Nero_X


This video can help you solving your question :)
By: admin