<form method="POST" id="uploadForm" enctype="multipart/form-data"> <input type="file" id="config" name="configFile"> <input type="file" id="demand" name="demandFile"> </form> button id="progressBtn" class="btn btn-primary">計算</button> <script> document.querySelector("#progressBtn") = function () { var formdata = new FormData() formdata.append("configFile", $("#config")[0].files[0]) formdata.append("demandFile", $("#demand")[0].files[0]) $.ajax({ type: "POST", url: "/api/computeResult", data: formdata, async: false, contentType: false, processData: false, success: function (res) { }, error: function (res) { } }) } </script>
注意:ajax