未捕获的类型错误:$(..).modal不是具有远程url的函数

Uncaught TypeError: $(...).modal is not a function with remote url

本文关键字:函数 url modal 类型 错误      更新时间:2023-09-26

我正在尝试打开按钮的click上的Bootstrap模式窗口。模式窗口正在打开一个外部页面(原点相同)。

Please look into JS Fiddle for more clarification.
https://jsfiddle.net/deveshmishra/frubmp1y/

错误:当我点击按钮时,我得到了一个错误,即:

未捕获的类型错误:$(…).modal不是函数。

有趣的是,每次我都没有犯这个错误。有时它工作得很好,但有时,它不起作用。另一件事是,只有当我加载外部页面时,它才会出现。否则它会很好用。

问题已解决。https://jsfiddle.net/frubmp1y/5/检查一下-

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js">    </script>
</head>
<body>
<div class="container">
<h2>Open a Popup Window</h2>
<button id="openModal" type="button" class="btn btn-default">Bootstrap Popup</button>

<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
            <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </div>
</div>
</div>
<script>
    $(document).on("click", "#openModal", function (){
        var url = "http://testing.dev/index.html";
        $('#myModal').modal({ show: 'true', remote: url })
    });
 </script>