dongxie7683 2019-08-13 09:55
浏览 24

使用字符串从php更改bootstrap的内容

I have a modal in an html page as shown below:

<!-- Modal -->
  <div class="modal fade" id="uploadImages" role="dialog">
    <div class="modal-dialog modal-lg">

      <!-- Modal content-->
      <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">&times;</button>
      <h4 class="modal-title">Upload Scanned Images</h4>
    </div>
    <div class="modal-body">
         <form action="upload.php" method="POST" enctype="multipart/form-data">
            Select file : <input type='file' name='U_FILES[]' id='file' class='form-control'  multiple=""><br>
             <input type='submit' class='btn btn-info' value='Submit' id='upload' name = 'submit'>
            </form>
    </div>
    <div class="modal-footer">
     <p>Only jpeg, png, bmp and tiff Images are allowed to be uploaded</p>
    </div>
      </div>

    </div>
  </div>

I also have a php file where I am outputting whether an output has been successful or not through an echo.

    for ($i = 0; $i < count($response); $i++) {
    echo $response[$i]["fileName"]." - ".$response[$i]["msg"]."<br/>";
}

Is it possible that instead of an echo I pass the response to the same modal body?

  • 写回答

1条回答 默认 最新

  • douwei8672 2019-08-13 11:11
    关注

    You can use ajax to submit form based on your response, also you can display message on same model.

    <!-- Modal -->
      <div class="modal fade" id="uploadImages" role="dialog">
        <div class="modal-dialog modal-lg">
          <div id="alertMsg"></div>
          <!-- Modal content-->
          <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×</button>
          <h4 class="modal-title">Upload Scanned Images</h4>
        </div>
        <div class="modal-body">
             <form method="POST" enctype="multipart/form-data" id="form_submit">
                Select file : <input type='file' name='U_FILES[]' id='file' class='form-control'  multiple=""><br>
                 <input type='submit' class='btn btn-info' value='Submit' id='upload' name = 'submit'>
                </form>
        </div>
        <div class="modal-footer">
         <p>Only jpeg, png, bmp and tiff Images are allowed to be uploaded</p>
        </div>
          </div>
    
    </div>
      </div>
      <script>
      $.ajax({
            url: 'path/to/php/upload.php',
            type: 'POST',
            data: $('#form_submit').serializeArray()
            success: function(response) {
                var tempResponse = JSON.parse(response);//if you are getting json array in response then this line is needed otherwise pass response directly in below html
                $('#alertMsg').html(tempResponse);
            }
        });
      </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类