I have to send some parameter to an IFRAME with POST method. I have read here Setting the HTTP request type of an <iframe> that it isn't possible. I'm thinking a solution in Javascript but I can't implement it so I can't test if it is a valid solution for this issue. I want to ask if someone has the same problem and if it is possible to solve and in positive case how to?
You can use a script to get the desired parameter value from parameters passed to page. Show activity on this post. If you have slightly more control on your iframe sandbox, you can try postMessage API to communicate with message on events you desire to trigger.
No. The URL specified by the src attribute is used to make a GET request. You can get the results of a POST request to display in an iframe, but that requires that you submit a form with target="name_of_iframe" and not just use the src attribute.
Doesn't take any JavaScript or anything. You just have the form's target attribute match the iframe's name attribute. The outer page doesn't even reload.
In a GET request, the parameters are sent as part of the URL. In a POST request, the parameters are sent as a body of the request, after the headers. To do a POST with HttpURLConnection, you need to write the parameters to the connection after you have opened the connection.
<form ... target="hidden_iframe"> ... </form> <iframe name="hidden_iframe" ...></iframe>
How about using the target attribute of the form to point to iFrame?
<form target="myIframe" action="http://localhost/post.php" method="post"> <input type="hidden" value="someval" /> <input type="submit"> </form> <iFrame src="" name="myIframe"></iFrame>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With