使用POST数据重定向 [英] Redirect with POST data
问题描述
我正在使用不同的API处理带有多种付款方式的购物车。
I am working on a shopping cart with several payment options using different APIs.
我想要的流程是用户选择要使用的付款方式和相应的表单显示。
The flow I want is that the user chooses which payment option to use and the according form shows.
提交时,有关地址等的表单字段应保存在我的数据库中,有关付款的字段将通过POST发送到付款处理程序api。
On submit the form fields regarding address etc should be saved in my DB and the fields regarding payment is sent with POST to the payment handler api.
用户只需单击一次就可以了,因此必须在点击提交按钮和数据发送到数据库之间挤压db-save-db。支付服务器。
It is important that the user only have to click once so the save-in-db has to be squeezed in between the click on the submit button and when the data is sent to the payment server.
我想到了一个重定向,其中所有数据都发送到POST并将数据保存在数据库中并重定向到支付服务器但是我如何重定向以及POST数据(不幸的是,GET无法正常工作)。
I have thought of a redirect where all data gets POSTED to and that save the data in DB and redirect to payment server BUT how do I redirect along with POST data (GET is not working unfortunately).
推荐答案
您无法发送传统的位置:
HTTP客户端的标头,用于执行重定向并包含POST数据。您可以做的是:
You can't send a traditional Location:
header to the HTTP client to do a redirect and include POST data. What you could do instead is:
- 使用AJAX请求获取正确的目标网址
- 通过JavaScript(在AJAX回调函数中)使用该URL更新表单操作
- 提交表单
这篇关于使用POST数据重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!