0

I try simulate post data within a form representing to:

<form id="new-order-form" action="https://sample.url" method="POST">
  <input name="pId" type="text" value="pId" />
  <input name="pPrice" type="text" value="pPrice" />
  <input name="pWallet" type="text" value="pWallet" />
  <input name="pAmount" type="text" value="pAmount" />
  <button type="submit">send</button>
</form>

Unfortunately, I cannot simulate it with the redirect also.

I try:

<form id="new-order-form" :action="payUrl" method="POST">
  <input name="pId" type="text" :value="pId" />
  <input name="pPrice" type="text" :value="pPrice" />
  <input name="pWallet" type="text" :value="pWallet" />
  <input name="pAmount" type="text" :value="pAmount" />
  <button type="submit">send</button>
</form>

Then assign values and triggering with jQuery: $('#new-order-form').submit()

Second option is with formData, but I cannot be redirected.

I try:

var formData = new FormData()
formData.append('pId', this.identification)
formData.append('pPrice', this.price)
formData.append('pWallet', this.ethWallet)
formData.append('pAmount', this.investAmount)
this.$http.post(this.payUrl, formData)

What is the most effective way? Which can simulate the POST form in the closest way?

acdcjunior
  • 132,397
  • 37
  • 331
  • 304
Maximi
  • 559
  • 5
  • 18
  • Possible duplicate of [How to submit a form using javascript?](https://stackoverflow.com/questions/9855656/how-to-submit-a-form-using-javascript) – Roy J Mar 05 '18 at 00:55
  • This is not clear. You want to be redirected and is not being redirected or you DON'T want to be redirected and IS being redirected? – acdcjunior Mar 05 '18 at 01:04
  • I want simulate normal POST like in HTML. Most of the code can send the request, but no redirection to form's action URL. – Maximi Mar 05 '18 at 09:58

0 Answers0