1

I'm trying to submit a form as a POST request with pre-loaded data to a site with no API. I have wrapped my form inside an iframe element, hoping to isolate it. However, the page still changes to the action page. How can I trap it in to prevent this?

Some answers to similar questions suggest setting the response's Content-Type to text/plain to force the browser to treat it as a document instead of a file. However, please note that I don't have access to the other end.

Kudu
  • 5,470
  • 8
  • 24
  • 27

1 Answers1

3

No need to wrap the form in an iframe. Keep the form on the main page and create a hidden, separate iframe on the same page. Then you need to use the form's target attribute to let the iframe become the target for the result of the POST operation. This way when submitting the form you will stay on the page, and the results will get loaded into the iframe.

This blog should help and also the answer to this question.

Community
  • 1
  • 1
emboss
  • 36,575
  • 7
  • 93
  • 103