'Stl file can not be shown when opening in a modal

There are two buttons for stl file 1 and stl file 2

<button type="button" class="btn btn-info btn-lg" id="open_modal" data-toggle="modal" data-target="#myModal" data-value="3.stl">Open Modal</button>

<button type="button" class="btn btn-info btn-lg" id="open_modal" data-toggle="modal" data-target="#myModal" data-value="4.stl">Open Modal2</button>

Modal be like

<div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div id="stl_cont" style="width:500px;height:500px;margin:0 auto;"></div>
    </div>
        
 </div>
Js is like
<script src="js/stl_viewer.min.js"></script> 
    <script>
    $(document).ready(function(){
      $(".btn-lg").click(function(){
        $("#stl_cont").html("");
        //$("#myModal2").remove();
        var del = $(this).attr("data-value");
        alert("/stlmodal/"+del);
        if(stl_viewer)
        stl_viewer.remove_model();
        var stl_viewer=new StlViewer
             (
                 document.getElementById("stl_cont"),
                 {
                     models:
                     [
                         {filename:"/stlmodal/"+del}
                     ]
                 }
             );
      });
    });
    </script>

First time when I am clicking a button its showing the stl file that is okay but when I click again in the another button in network I am seeing the error like enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source