简体   繁体   中英

Its possible to POST a form with AJAX to java servlet and redirect?

I explain my problem:

I have one JSP webpage and I have one AJAX call that send some data to one servlet.

The servlet that receive the data have to send this data and more other information to an external URL. This external URL have to be load in the screen with the POST params sent.

Its possible to do this with AJAX and JAVA?

I know that the easy way is send a normal FORM from MYPAGE to this external website (without the servlet) and the form automatic redirects to this external URL, but I dont have all the data, so I need one intermediate servlet to get it...

The schema:

MYPAGE -- (AJAX request to one servlet)---> MY SERVLET ---(POST to an URL with params)---> EXTERNALWEBSITE

The user have to see in the screen the EXTERNALWEBSITE like if the call would be direct between MYPAGE and the EXTERNALWEBSITE

You could send the additional data that you need in the response of your Ajax call. Then on the client-side, right after your Ajax call, you can do a jQuery.post() to the external URL that will include all the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM