Getting bootstrap modal content from another HTML file

Viewed 2724

So basically what I'm trying to achieve is getting the content of a bootstrap modal from another html file instead of placing the modal content on the index html file (because I will need to use it multiple times).

I've tried searching high and low for an answer, and the closest that I've got is this: Getting Bootstrap's modal content from another page

However, I have a problem because it is not showing any of the modal content. It is just displaying a blank modal and I have no idea where I have gone wrong.

Below are my relevant codes: Main HTML:

<div class="panel panel-default">
    <div class="panel-heading">
        <i class="fa fa-bar-chart-o fa-fw"></i> Pre-IDA Test
    </div>

    <div class="panel-body">
        <div id="chartdiv" style="width: 100%; height: 400px;"></div>
        <script> pretest() </script>
        <a href="pretestmodal.html" class="btn btn-info" data-toggle="modal" data-target="#testing">View Data</a>
        <div id="testing" class="modal fade" role="dialog" tabindex="-1" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                </div>
            </div>
        </div>
    </div>
</div>

Modal Content:

<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    </head>
    <body>

    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Details</h4>
    </div>
    <!-- /.modal-header -->
    <div class="modal-body">
        <div class="table-responsive">
            <table class="table table-bordered table-hover table-striped">
                <thead>
                    <tr>
                        <th>Year/Quarter</th>
                        <th>Indoor Quarterly Results</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>2016 Q1</td>
                        <td>Q1 (59/60)</td>                
                    </tr>
                    <tr>
                        <td>2016 Q2</td>
                        <td>Q2 (58/60)</td>     
                    </tr>
                </tbody>
            </table>
        </div>
        <!-- /.table-responsive -->
    </div>
    <!-- /.modal-body -->
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
    </div>
    <!-- /.modal-footer -->
    </body>
</html>

EDIT: After looking at the JavaScript Console, I've found an error which says:

jquery.min.js:4 XMLHttpRequest cannot load file:///E:/PORTAL/pages/pretestmodal.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

Any idea how I can fix this?

2 Answers
Related