如何在表单中发送两个不同的操作,一个提交按钮[重复]

This question already has an answer here:

I have one actions that sends info to the journals.php and the second actions sends info to the uploads.php file. How can i do this with one submit button.

If you could show an example that would be awesome :)

        <form id="login" action="journal.php?journal=journals&id=<?php echo $opened['id']; ?>" method="post" role="form">

            <div class="form-group">

                <label for="title">Title</label>
                <input class="form-control" type="text" name="title" id="title" value="<?php echo $opened['title']; ?>" placeholder="Title">                    

            </div>
            <div class="form-group">

                <label for="body">body</label>
                <textarea class="form-control" name="body" id="body" rows="14" placeholder="body"><?php echo $opened['body']; ?></textarea>                    

            </div>


            <button type="submit" id="loginSubmit" class="btn btn-default">Save</button>
            <input type="hidden" name="submitted" value="1">
             <?php if(isset($opened['id'])) { ?>
                 <input type="hidden" name="id" value="<?php echo $opened['id']; ?>">
            <?php } ?>

        </form>

          <form action="uploads.php" enctype="multipart/form-data">

            <input type="file" name="file">

        </form>

I have now tried to make this script.

    <script type="text/javascript">
     $(document).ready(function() {     

$("#Login").click(function(e) { 
    e.preventDefault();

    $.ajax({
        type: "POST",
        url: "uploads.php",
        datatype: "html",
        data: $("#loginSubmit").serialize(),
        success: function(data) {                   
        }
    });

    $("#loginSubmit").submit();
});

 });

   </script>
</div>

You can submit the text form with AJAX, wait for it to come back successfully, and then submit the file form regularly.

OR

You can make a single action file and include journal.php and uploads.php in it.