The following code is used to ajax-load a div.
The only issue I have with it is that .html() renders raw html, and so I thought it might be a good idea to replace that with a pure JS alternative so that my view is clean of any escaping raw html.
I'd love to hear your thoughts about this.
$(document).ready(function() {
$('.ajax_load').each(function(index, element) {
var url = $(element).data('remote-url')
if (url) {
$.get(url, function(responseText) {
$(element).html(responseText);
})
} else {
console.log("missing url for ajax!")
}
})
})
$(element).text(responseText)instead if you just want to disable rendering raw html.element.innerHTML = '<some divs>'used in your site footer will basically remove the need forreadyand many other old and not very performant jQuery methods.