[wordpress modal ajax点击载入php文件

问题描述 投票:0回答:1

[嗨,如果有人可以建议如何在我的wordpress主题中加载我的自定义php文件。我只想在单击模式按钮时才加载php文件

 var modal = document.getElementById("myModal");
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0]; 
btn.onclick = function() {
  modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
  modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
}   

    <!-- Trigger/Open The Modal -->
    <span class="close">&times;</span>

    <!-- The Modal -->
    <div id="myModal" class="modal">

      <!-- Modal content -->
      <div class="modal-content">
    <div class="modal-body">


   please wait while content loads .....


  <?php get_template_part( 'content-modal.php' ); ?>

     </div>
      </div> </div>

任何建议,将不胜感激,谢谢

ajax wordpress modal-dialog
1个回答
0
投票

据我了解,您希望在页面加载并单击myBtn之后从服务器获取信息。如果是这样,您将无法从服务器获取信息或php代码,除非您调用ajax函数或发送导致重新加载页面的请求(如GET / POST)。

© www.soinside.com 2019 - 2024. All rights reserved.