Two different submit form actions

I have a form with a submit button. I called the function when I clicked the submit button.

function actionPage(form1) { form1.action="action1.php"; form1.submit(); return(true); } 

Now I want the form data to be presented on two different pages. These pages are located on different servers.

I know that we can send data to a specific page in accordance with the conditions, but I'm not sure if we can simultaneously send to two different pages: ie:

 function actionPage(form1) { form1.action="action1.php"; form1.submit(); return(true); form1.action="action2.php"; form1.submit(); return(true); } 

Now it shows action1.php

+4
source share
4 answers

you cannot do this using a simple post submit form. but you can do it with AJAX.

as soon as you call submit () fn, the data from the form will be sent to the action url page. therefore, you can load the loaded page.

+4
source

You can not. You can send data to several places using XmlHttpRequest.

+3
source

You cannot submit the form in several places. You can do this on the client side via AJAX, or you can post a form message on a page that will send data wherever it is. Using the AJAX approach, you will encounter problems sending to a different domain due to the same origin policy . I would suggest using cURL on the server side to send data to other domains.

+2
source

Just as simple:

 <form name=f1 type=post action=''> <input type='submit' value='first url' onclick="f1.action='/save'"> <input type='submit' value='second url' onclick="f1.action='/process'"> </form> 

Taken from: http://www.plus2net.com/html_tutorial/submit-two.php

+2
source

Source: https://habr.com/ru/post/1303199/


All Articles