Sometimes I like to do an Ajax request to the server, but instead of returning a json I return a html and append that html with jQuery html method. It's safe to use directly element.innerHTML
in this case?
The response is served using a Django server and its template system.
Instead of this:
function loadInfo(endpoint, container) {
$.get(endpoint)
.done(response => $(container).html(response))
}
Do this:
function loadInfo(endpoint, container) {
$.get(endpoint)
.done(response => container.innerHTML = response)
}
The point of doing this is to have dynamic behaviour on some parts of the page with a little javascript as possible