Jump to content

Asynchronous Loading Problem


niels

Recommended Posts

Hey everybody,

I'm hving a problem with a script I'm using and I hope somebody could help on the forum.

I started implementing the facebook like button. I noticed they encouraged you to use this piece of code :

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: 'your app id', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>

Now that doesn't work for me at the moment and I thought it had something todo with the special htmltag you need to use so I thought to implement my on script loading this way first.

Easy enough I thought but after 2 days searching around, and I'm not that familiar with javascript or jquery.

I wrote this piece of script to load my own jquery(this part is work correctly because I tried the static linking first).

<script type="text/javascript">
		  //<![CDATA[
		   (function() {
		    var e = document.createElement('script'); 
		    e.type = "text/javascript";
		    e.async = true;
		    e.src = ('/js/general.js');
		    var x = document.getElementsByTagName('script')[0];
		    x.parentNode.insertBefore(e, x);
		  });
		//]]>
    </script>

I followed a tutorial somewhere online, just replace the write url but it didn't worked sadly enough.

I hope there are some javascript master on the forum who could help with some tips.

Maybe give be some links to good javascript tuts

Thanks in advance

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...