I have a javascript code snippet at the end of my pages. The code works on page load, but I wish to fire this code after an ajax request as well as on page load. The javascript code is as follows:
(function(d, t) {
var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
g.src = '//api.reftagger.com/v2/reftagger.js';
s.parentNode.insertBefore(g, s);
}(document, 'script'));
I moved this function inside the ajax .get call of my plugin and now it works successfully on ajax calls. However I still need it be included at the end of the page to make it work without ajax as well.
How can I include both without making one cancel out the other?
EDIT: I fixed using a conditional statement to exclude on ajax pages. Thanks everybody!