I have the following, I have 4 html files with different information that I need to show as necessary, I already have this done and it works but I do not know if it is the correct way or it can be improved, I appreciate your help
Index.php
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
</div>
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Ventana Modal con Bootstrap</h3>
</div>
<div class="panel-body">
<ul>
<li><a href="javascript:void(0);" data-toggle="modal" data-target="#myModal" onclick="carga_ajax('12','myModal','ajax_1.html');">Modal 1</a></li>
<li><a href="javascript:void(0);" data-toggle="modal" data-target="#myModal" onclick="carga_ajax('12','myModal','ajax_2.html');">Modal 2</a></li>
</ul>
</div>
</div>
</div>
Function
function carga_ajax(id,div,url){
$.post
(url, {id:id}, function(resp){
$("#"+div+"").html(resp);
}
);
}
And this is the modal_info01.html file that will contain the information
<!-- Modal -->
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Este es Modal 2</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
As I was saying ... this works if the query works .... it's the best way to do it or it can be improved
The only question I would ask you is why you should put this line in the index
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
</div>