Php 如何通过单击一个按钮在一个表单提交中调用两个操作?

Php 如何通过单击一个按钮在一个表单提交中调用两个操作?,php,mysql,Php,Mysql,我有一个PHP表单。当我点击提交按钮时,我想同时执行两个操作。我该怎么做 <script> function myfunction(){ $.ajax({ type: 'post', url: 'merchants.php', data: $('form').serialize(), success: function () {

我有一个PHP表单。当我点击提交按钮时,我想同时执行两个操作。我该怎么做

<script>
     function myfunction(){

          $.ajax({
            type: 'post',
            url: 'merchants.php',
            data: $('form').serialize(),
            success: function () {
              alert('form was submitted');
            }
          });
      }


    </script>

<div class="stdFormHeader"> New Merchant Registration</div>
<form action="" method="POST">
    <label class="stdFormLabel">Merchant name : </label><input class="stdFormInput" type="text" name="merchantName" required><br>
<!--    <label class="stdFormLabel">Business Type : </label><select class="stdFormSelect" name="shopMarket" required>-->
<!--        <option value="shop">Shop</option>-->
<!--        <option value="market">Market Place</option>-->
<!--    </select><br>-->
    <label class="stdFormLabel">Contact Person : </label><input class="stdFormInput" type="text" name="contactPerson" required><br>
    <label class="stdFormLabel">Contact Number : </label><input class="stdFormInput" type="text" name="contactNumber" required><br>
    <label class="stdFormLabel">Address : </label><textarea class="stdFormInputBox" name="address"></textarea><br>

    <input class="stdFormButton"  type="submit" name="submit" onclick="myfunction()" value="Apply">
</form>

函数myfunction(){
$.ajax({
键入:“post”,
url:'merchants.php',
数据:$('form')。序列化(),
成功:函数(){
警报(“表格已提交”);
}
});
}
新商户登记
商户名称:
联系人:
联系电话:
地址:

只需再次提交:

 function myfunction(){

  $.ajax({
    type: 'post',
    url: 'merchants.php',
    data: $('form').serialize(),
    success: function () {
      alert('form was submitted');
    }
  });

  $.ajax({
    type: 'post',
    url: 'OtherFunction.php',
    data: $('form').serialize(),
    success: function () {
      alert('form was submitted again');
    }
  });
}

什么样的行动?例如,当按下submit按钮时,javascript可以监听并执行操作。无论如何,请参观一下帮助中心,看看如何提出一个好问题。如果您不提供任何代码,我们将无法帮助您-请参阅如何创建最小、完整且可验证的示例什么操作?这两项都可以在服务器端完成吗?如果是这样,请向表单目标处理程序添加更多代码。以上是我的代码。我目前正在通过ajax提交我的表单。我也想将这些数据发送到另一个文件。如何使用相同的窗体和按钮执行两个操作?