Reputation: 6888
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.
Upvotes: 1
Views: 1692
Reputation: 39650
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.
Upvotes: 3