<button type="button" class="btn btn-primary" data-toggle="modal" data-id="1">Modal 1</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-id="2">Modal 2</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-id="3">Modal 3</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<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">Modal title</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>
</div>
</div>
$(function() {
$('.btn').click(function() {
/*Lese ID des aktuellen Buttons ein*/
var id = $(this).data('id');
var myModal = $('#exampleModal');
/*Führe Ajax-Anfrage durch mit ID als Parameter*/
$.get('/files/modal-content-example.php', {id: id}, function(response) {
/*Inhalt der Ajax-Anfrage in Modal einfügen*/
myModal.find('.modal-content').html(response);
/*Modal anzeigen*/
myModal.modal('toggle');
});
});
})