In my HTML page, I have a modal :
<div class="modal fade">
.....
<div class="modal-body" id="{{ modalId ~ 'Body' }}">
**** I want load HTML with Ajax here ********************
</div>
</div>
I want to load HTML dynamically with ajax in my modal body, like this :
$.ajax({
url: Routing.generate('XXXXXXXXX', {'id' : $(this).data('id')}),
type: 'GET',
async: true,
success: function (data) {
$('#modalViewMailBody').html(data);
}
});
My problem is that the data (html) returned contains CSS and another html, head and body tags.
It creates conflicts and impacts the visual of the base screen.
Any ideas to escapte this problem ?
Thank you in advance.
2
Answers
Create an endpoint in the controller and call it via the ajax function. You have to return the twig file in the controller method which will be used in your ajax function success response.
});