<p>Ich bin ein Text, <span id="myButton">klicke hier</span>, damit sich das Modal öffnet.</p>
<!-- 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() {
$('#myButton').click(function() {
/*Lese ID des aktuellen Buttons ein*/
var myModal = $('#exampleModal');
/*Führe Ajax-Anfrage*/
$.get('/files/modal-content-example.php', function(response) {
/*Inhalt der Ajax-Anfrage in Modal einfügen*/
myModal.find('.modal-content').html(response);
/*Modal anzeigen*/
myModal.modal('toggle');
});
});
})