等待通过JSON加载值,然后加载外部JavaScript

时间:2013-06-18 16:19:59

标签: javascript jquery

我使用以下函数来设置addthis:title属性:

function setTheTitle(){
        if(jQuery(".title").length > 0){
            shareTitle = jQuery(".title").text();
            jQuery("#shareButton").attr("addthis:title", shareTitle);
        } else {
            setTimeout(function(){
                setTheTitle();
            },100)
        }
    }

问题是, shareTitle 变量是通过JSON对象生成的,需要几秒钟才能加载。

在此之前,addthis javascript加载,并看到空url attr ,设置页面默认标题。

<script src="http://www.../external_share_script.js" type="text/javascript">share script</script>
<a href="#" id="shareButton" addthis:title="" addthis:url="">the link</a>

如何在我获得价值之前延迟addthis javascript的加载?

0 个答案:

没有答案
相关问题