I am trying to create a bootstrap modal which contains the result of an AJAX request.
my bootstrap code is as follows
{{--Bootstrap modal--}}
<div id="exampleModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Electronic mail title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Electronic mail body text goes here.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
There is also a button, as you can see its HREF attribute makes a call to the route which is intended to be called via AJAX.
<a href="api/myroute/someID" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">Preview Reminder</a>
I have written the back end code which returns content from api/myroute/someID
So far the front end code is sample code copy/pasted from bootstraps documentation and the back end code is my own.
The next step is to write some Javascript which takes the content of the AJAX call to api/myroute/someID and place it in the modal window.
The problem is that although I have NOT YET WROTE THIS CODE The content returned from this route is getting placed in the modal window automatically.
However this only works correctly once. Opening a second modal window and putting a different "someID" on the end of the route (so it returns different data) results in a modal window that contains the result of the first AJAX call.
I have 2 questions.
1) How is this working? 2) How do i make it refresh the content of the modal each time it is opened