Facebook like: Uncaught TypeError: Object # <a object> does not have a 'provide' method

I recently added a facebook button, but the following code returns an error in chrome: Uncaught TypeError: Object # does not have a "provide" method

<!-- Facebook --> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({appId: '121814204514513', 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> <!-- Facebook --> 

A similar button works, but the error is anonymous, does anyone know how to solve it?

thanks

+4
source share
3 answers

I recently had the same issue when I tried to enter http://connect.facebook.net/en_US/all.js in Google Reader (for this exciting Kynetx coding contest: http://code.kynetx.com/2011/ 04/26/250-to-build-kynetx-facebook-send-within-24hrs-ends-apr-27th / ). all.js begins with "if (! window.FB) window.FB = {..." and declares a "provide" method. The FB object was already present in the Google reader (I don’t know why and how it was created), so the code inside the if has never been executed. The trick I used was to set the FB to null before turning on http: // http: //connect.facebook.net/en_US/all.js . "Google Reader didn't complain. It could be a solution to your situation Update: You may need to set the FB value as follows:

 var head = $("head").get(0); // using jquery var script2 = document.createElement("script"); script2.innerHTML = "window.FB = null;FB=null;"; head.appendChild(script2); 
+7
source

Although, the code provided by Loyk Devo will do the trick you don't need in your case. It solves the markup problem shown on a third-party website ...

I had the same problem and initially I added this code to solve it. Then I thought that there must be something wrong, and I did not do everything right. I added a facebook comment box to a page that already had a facebook share button. So I just moved the script resource after the script was initialized, and the error went away.

My advice is to check if you have more than one FB widget on your pages. If so, read the documentation and make sure you add the correct scripts to the right place.

+2
source

Loic solution does not work in IE. Instead, you should do this:

 var head = $("head").get(0); // using jquery var script2 = document.createElement("script"); if (!$.browser.msie ) { script2.innerHTML = "window.FB = null;FB=null;"; }else{ script2.text = "window.FB = null;FB=null;"; } head.appendChild(script2); 
+1
source

Source: https://habr.com/ru/post/1313764/


All Articles