dongshao8471 2018-06-04 07:11
浏览 42
已采纳

显示模态而不是回显消息

if (mysqli_num_rows($res_username) > 0) {
    //echo "Sorry... Username already taken";
    echo "<script>$('#RegisterModal').modal('show')</script>";
}

<div id="RegisterModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            You have sucess registered!
        </div>
    </div>
</div>

For the echo part, I want to display a modal showing a popup instead of a echo message. Anybody help?

  • 写回答

1条回答 默认 最新

  • doubipiao1611 2018-06-04 07:18
    关注

    Enclose your script in $(document).ready() so your show command executes only when the document is fully loaded to limit failure.

    Like:

    echo "
      <script>
      $( document ).ready(function() {
      $('#RegisterModal').modal('show')
      });
      </script>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?