I am trying to preload an html file whose contents will subsequently be used on several expandable buttons spread throughout a website.
The problem is that only the content of the first button of the page gets loaded this way, the rest of the buttons show nothing when expanded.
I do have noticed that there are other questions here on SO about similar issues, but none of the solutions I've come across seemed to work in this case. Therefore, any help will be greatly appreciated.
Relevant part of the script:
$(document).ready(function () {
var thisLink = $("a.ajax-link");
var targetUrl = thisLink.attr("data-href");
var target = thisLink.data("ajaxtarget");
$(target).each(function( index, btn ) {
$(this).load(targetUrl, function () {
console.log('Success');
});
});
});
If there is any other piece of information that could be of use to you, please let me know. Thank you very much for your time