I know that it is possible to submit POST request to an iframe by using target
attribute.
Is there any way to submit POST request from one form to multiple iframes at the same time?
Both HTML and JS solutions are acceptable.
I know that it is possible to submit POST request to an iframe by using target
attribute.
Is there any way to submit POST request from one form to multiple iframes at the same time?
Both HTML and JS solutions are acceptable.
A Javascript solution would be your best bet.
<form id="form">
<input type="text" name="xyz" value="random data" />
<button type="submit">Go</button>
</form>
In JS, you would attach an event listener to your form when it is submitted. The listener would trigger a function that could send the form data to multiple targets:
var form = document.getElementById("form");
if(form.attachEvent) {
form.attachEvent("submit", submitForm);
} else {
form.addEventListener("submit", submitForm);
}
function submitForm(e) {
if(e.preventDefault) {
e.preventDefault();
}
this.target = "first_iframe";
this.submit();
var secondForm = this.cloneNode();
secondForm.target = "second_iframe";
secondForm.submit();
}