0

Simple html question. Is it possible to send data from html forms, like normal using "action" to two different scripts? Or is there any other way to do that? Besides using curl.

4

4 回答 4

3

使用 jquery 触发对两个单独脚本的两个 ajax 调用。

$('#button').click(function(){
  $.ajax({
    url: 'script1.php'
  });
  $.ajax({
    url: 'script2.php'
  });
)};

这是一种快速而肮脏的方法......显然为它们添加了错误检查和成功检查,以确保两者都正确提交。

理想的方法是使用 cURL,它避免了 js/客户端问题,以及避免额外的不必要的 http 请求。

于 2012-04-10T21:02:05.923 回答
3

为什么不将其发送到一个脚本,然后将其发送到所需的函数来处理它?

于 2012-04-10T21:02:42.910 回答
1

普通的 action 属性无法做到这一点,但您可以使用 Javascript 轻松做到这一点。不过,如果没有看到一些代码,我无法提供太多示例。

form.onsubmit(function(){
   senddata(here);
   senddata(there);
});
于 2012-04-10T21:01:52.560 回答
1

一个主意 :

  • 将数据从表单发送到脚本 A
  • 获取脚本 A 将数据发送到脚本 B(一旦收到)
于 2012-04-10T21:02:04.000 回答