表单提交上的两个不同操作 [英] Two different actions on form submit

查看:135
本文介绍了表单提交上的两个不同操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有提交按钮的表单。我在点击提交按钮时调用了一个函数。

I have a form with a submit button. I have called a function on click of submit button.

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

现在我希望表单数据应该提交给两个不同的页面。这些页面位于不同的服务器上。

Now I want that the form data should be submitted to two different pages. These pages are on different servers.

我知道我们可以根据条件将数据发送到特定页面,但我不确定是否可以提交给两个不同的页面页面同时即:

I know that we can send the data to a particular page according to the conditions but I am not sure whether we can submit to two different pages at the same time i.e:

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

}

现在它正在显示action1.php

Right now it is showing action1.php

推荐答案

你不能使用简单的表格提交提交。但你可以使用AJAX。

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

当你调用submit()fn时,表单中的数据会被发布到动作网页。因此你最终可能会加载页面。

as you soon as you call submit() fn, the data from the form is posted to the action url page. hence you might end up page being loaded.

这篇关于表单提交上的两个不同操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆