I have a javascript function which makes an external call to an API which in turn injects some HTML into my page.
Now i want to execute a function which checks this script and if it does not inject the HTML into my page i want to do something else here. The problem is i cannot call this function on document.ready
nor window.load
as the first script to the external API gets executed after these 2 events.
The script is something like below:
(function () {
var o = ccs_cc_args; o.push(['_SKey', '35455c2f']); o.push(['_ZoneId', '311e740881']);
var sc = document.createElement('script'); sc.type = 'text/javascript'; sc.async = true;
sc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.cnetcontent.com/jsc/h.js';
var n = document.getElementsByTagName('script')[0]; n.parentNode.insertBefore(sc, n);
})();
Now the function I wrote is like below:
$(document).ready(function () {
if ($("#ccs-inline-content").html() == "") {
$('#ProductDetails > ul li:has(a[href="#tabs-1"])').hide()
$("#ProductDetails").tabs('refresh');
$("#ProductDetails").tabs('option', 'active', 1);
}
});
So i need to force the second function to run after the first script which does not happen.