javascript - Multiple facebook post via jquery -


i'm trying post multiple facebook post on page using jquery. far getting success post first facebook post not able post another.

what happening?

facebook post embed url

<div id="fb-root"> </div><script> (function(d, s, id)  {    var js, fjs = d.getelementsbytagname(s)[0];    if (d.getelementbyid(id)) return;    js = d.createelement(s);   js.id = id;     js.src = "//connect.facebook.net/en_us/sdk.js#xfbml=1&version=v2.3";       fjs.parentnode.insertbefore(js, fjs);  } (document, 'script', 'facebook-jssdk')); </script> <div class="fb-post" data-href="https://www.facebook.com/clashofclans/posts/1104473549576967:0" data-width="500"> <div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/clashofclans/posts/1104473549576967:0"> <p>the update here!!! maintenance start soon! read that&#039;s new: http://supr.cl/updatenotes </p> posted  <a href="https://www.facebook.com/clashofclans">clash of clans</a> on&nbsp; <a href="https://www.facebook.com/clashofclans/post/1104473549576967:0">wednesday, july 1, 2015</a> </blockquote> </div> </div> 

when append url directly div, calls iframe , complete facebook post data binds on dom. works next time iframe not loading on dom. in console first time found app error ie invalid app id: must number or numeric string representing application id.. tried correct appid not succeed. below code i've tried far

$("input").blur(function ()  {    $('div').html($(this).val());    //$(this).val() facebook post url shown above  }) 

will please suggest me correct way of doing ?

use following code. factors when code loaded. answer created using source working asynchronously loaded javascript can wrap getloginstatus call in loop if will.

    <!doctype html> <html>     <head>         <title></title>         <script src="jquery-1.11.1.min.js"></script>     </head>     <body>         <input type="text" id="message" />         <input type="button" id="send" value="send" />     <script>         $(document).ready(function(){             function facebookready() {                 fb.init({                     appid      : '1521775134725984',                     xfbml      : true,                     status   : true,                     cookie     : true,                     version    : 'v2.1'                 });                 $(document).trigger("facebook:ready");             }              if(window.fb) {                 facebookready();             } else {                 window.fbasyncinit = facebookready;             }         });          $(document).on("facebook:ready", function() {              $("#send").on("click", function() {                 fb.getloginstatus(function(response) {                     if (response.status === 'connected') {                         var body = $("#message").val();                         fb.api('/me/feed', 'post', { message: body }, function(response) {                             if (!response || response.error) {                                 alert('error occured');                             } else {                                 alert('post id: ' + response.id);                             }                         });                     }                     else {                         fb.login(function(){                         }, {scope: 'publish_actions'});                     }                 });             });         });      (function(d, s, id){         var js, fjs = d.getelementsbytagname(s)[0];         if (d.getelementbyid(id)) {return;}         js = d.createelement(s); js.id = id;         js.src = "//connect.facebook.net/en_us/sdk.js";         fjs.parentnode.insertbefore(js, fjs);     }(document, 'script', 'facebook-jssdk')); </script>     </body> </html> 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -