![](/img/trans.png)
[英]How do i receive form data from the dynamically created JavaScript form fields into JSP?
[英]ReactJS: how do I receive form data from external application
我有一個 ReactJS 應用程序。 該應用程序將表單提交到外部 url。 因此,當提交表單時,如果發生錯誤,位於外部 url 的服務器會使用表單中提供的重定向 url 將錯誤消息和狀態發送回應用程序。 所以我想要的是能夠讀取從外部應用程序發送的 POST 表單數據,這樣我至少可以顯示錯誤。 我遇到的問題是,當外部服務器重定向到我提供的 url 時,它在截獲的頁面上顯示“無法發布/”。 它甚至沒有在該頁面上加載組件,然后在控制台上顯示“無法加載資源:服務器響應狀態為 404(未找到):8000/#/payment-confirmation” 下面是我的路由器:
import PaymentPreview from './payment-preview';
import PaymentConfirmation from './payment-confirmation';
<Switch>
...
<Route path='/payment-preview' component={PaymentPreview} />
<Route path='/payment-confirmation' component={PaymentConfirmation} />
</Switch>
這是我發布到外部 URL 的表格
<form action="url-goes-here" method="POST" target="_blank">
<input type="hidden" name="product_id" value="10" />
<input type="hidden" name="pay_item_id" value="20" />
<input type="hidden" name="amount" value="5000" />
<input type="hidden" name="currency" value="599" />
<input type="hidden" name="site_redirect_url" value="http://localhost:8000/#/payment-confirmation" />
<input type="hidden" name="txn_ref" value="3834734873dshjhj3434" />
<input type="hidden" name="cust_id" value="5664" />
<input type="hidden" name="site_name" value="MySite" />
<input type="hidden" name="cust_name" value="Anietie Asuquo" />
<input type="hidden" name="hash" value="hash" />
<input type="hidden" name="mac" value="mac" />
<RaisedButton
type="submit"
label="Confirm & Pay"
primary={false}
className="normal-case"
keyboardFocused={true}
backgroundColor="#E53935"
labelColor="#ffffff"
fullWidth={true}
// onTouchTap={this.formSubmit}
/>
</form>
當我檢查 chrome 網絡選項卡時,我看到服務器發送的 formData,如何在我的頁面上獲取和處理它們? 我需要幫助。
我遇到了同樣的問題。 現在修好了
"site_redirect_url" should be https url
我無法從我的開發環境中修復它。 所以我將我的項目上傳到測試環境或生產環境,然后我將我的測試或生產域 url 轉換為https
。 最后它完美地工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.