Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8362453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:56:41+00:00 2026-06-09T11:56:41+00:00

I am trying to implement the basic features of facebook like updating the facebook

  • 0

I am trying to implement the basic features of facebook like updating the facebook profile, and also facebook login using jquerymobile frame work. Using this link http://thinkdiff.net/facebook/graph-api-javascript-base-facebook-connect-tutorial/

It works fine with HTML 5 format. But when I integrate with the JqueryMobile, I am getting an error which says Uncaught exception: cant call method appendChild.

I will paste the code here: please have a look and let me know whats the problem.

<body> 
<script type="text/javascript">
window.fbAsyncInit = function() {

                FB.init({appId: 'xxxxxxxxxxxxxx', status: true, cookie: true, xfbml: true});



                /* All the events registered */

                FB.Event.subscribe('auth.login', function(response) {

                    // do something with response

                    login();

                });

                FB.Event.subscribe('auth.logout', function(response) {

                    // do something with response

                    logout();

                });



                FB.getLoginStatus(function(response) {

                    if (response.session) {

                        // logged in and connected user, someone you know

                        login();

                    }

                });

            };

            (function() {

                var e = document.createElement('script');

                e.type = 'text/javascript';

                e.src = document.location.protocol +

                    '//connect.facebook.net/en_US/all.js';

                e.async = true;

                document.getElementById('fb-root').appendChild(e); //i am getting error in the is line

            });



            function login(){

                FB.api('/me', function(response) {

                    document.getElementById('login').style.display = "block";

                    document.getElementById('login').innerHTML = response.name + " succsessfully logged in!";

                });

            }

            function logout(){

                document.getElementById('login').style.display = "none";

            }



            //stream publish method

            function streamPublish(name, description, hrefTitle, hrefLink, userPrompt){

                FB.ui(

                {

                    method: 'stream.publish',

                    message: '',

                    attachment: {

                        name: name,

                        caption: '',

                        description: (description),

                        href: hrefLink

                    },

                    action_links: [

                        { text: hrefTitle, href: hrefLink }

                    ],

                    user_prompt_message: userPrompt

                },

                function(response) {



                });



            }

            function showStream(){

                FB.api('/me', function(response) {

                    //console.log(response.id);

                    streamPublish(response.name, 'Something ', 'hrefTitle', 'http://www.ffff.com', "Share www.ffffff.com");

                });

            }



            function share(){

                var share = {

                    method: 'stream.share',

                    u: 'http://www.fffffff.com'

                };



                FB.ui(share, function(response) { console.log(response); });

            }



            function graphStreamPublish(){

                var body = 'hsdfkjasdkjfadkjf;adlfj';

                FB.api('/me/feed', 'post', { message: body }, function(response) {

                    if (!response || response.error) {

                        alert('Error occured');

                    } else {

                        alert('Post ID: ' + response.id);

                    }

                });

            }



            function fqlQuery(){

                FB.api('/me', function(response) {

                     var query = FB.Data.query('select name, hometown_location, sex, pic_square from user where uid={0}', response.id);

                     query.wait(function(rows) {



                       document.getElementById('name').innerHTML =

                         'Your name: ' + rows[0].name + "<br />" +

                         '<img src="' + rows[0].pic_square + '" alt="" />' + "<br />";

                     });

                });

            }



            function setStatus(){

                status1 = document.getElementById('status').value;

                FB.api(

                  {

                    method: 'status.set',

                    status: status1

                  },

                  function(response) {

                    if (response == 0){

                        alert('Your facebook status not updated. Give Status Update Permission.');

                    }

                    else{

                        alert('Your facebook status updated');

                    }

                  }

                );

            }
            </script>
<div data-role="page">

    <div data-role="header">
        <h1>Foofys-Facebook Page</h1>
    </div><!-- /header -->

    <div data-role="content">   
        <p>you are using foofys facebook app</p>
         <div id="fb-root"></div>
<fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"> </fb:login-button>



        <p>

            <a href="#" onclick="showStream(); return false;">Publish Wall Post</a> |

           <!-- <a href="#" onclick="share(); return false;">Share With Your Friends</a> | -->

            <a href="#" onclick="graphStreamPublish(); return false;">Publish Stream</a> |

           <!-- <a href="#" onclick="fqlQuery(); return false;">FQL Query Example</a> -->

        </p>



        <textarea id="status" cols="50" rows="5">Write your status here'</textarea>

        <br />

      <!--  <a href="#" onclick="setStatus(); return false;">Status Set Using Legacy Api Call</a> -->



        <br /><br /><br />

        <div id="login" style ="display:none"></div>

        <div id="name"></div>       
    </div><!-- /content -->

    <div data-role="footer">
        <h4>Page Footer</h4>
    </div><!-- /footer -->
</div><!-- /page -->

</body>

i am not able to understand whats happening in the code, BTW I have just pointed where exactly I am getting the error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:56:43+00:00Added an answer on June 9, 2026 at 11:56 am

    The trick with JQM and FB api is to use the graph API. That is DO NOT use the simple javascript FB wrappers since they are unstable when exposed to JQM’s page handling – instead just use the new graph / rest API, check for and avoid multiple inits of the FB core and your’e set. For instance

    function updateUserInfo(uid, accessToken) {
    
        var uri = "https://graph.facebook.com/" + uid;
        console.log("About to call FP.api with URI " + uri);    
    
        $.ajax({
                    type: "GET",
                    url: "https://graph.facebook.com/" + uid,
                    dataType: "json",
                    success: 
                        (function (response) {
                            console.log("About to call check profile ...");
                            $("#p_name").val(response.name);
                            $("#email").val(response.email);
                            $("#fb_id").val(response.id);
                            $.ajax({
                                type: "POST",
                                url: "/check_profile",
                                cache: false,
                                data: {fb_id: response.id},
                                success: onCheckSuccess,
                                error: onError
                            });
                            console.log("FB id: " + response.id);                     
                        }),
                    error: onError
             });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very basic example of what I am trying to implement in
I'm trying to implement some basic entities using Hibernate/JPA. Initially the code was deployed
I'm trying to implement this basic example found here : under the section titled
This is probably something quite basic. I am trying to implement AdWhirl into my
I am trying to implement a basic Zope2 content type directly without using dexterity
I have this weird kind of error. I am trying implement basic Euclidean algorithm
Well i am trying to implement basic functionality of voice recording , like Record
I'm trying to implement basic auditing with some of my models (like CreatedAt, UpdatedAt,
I'm trying to implement basic auditing for a system where users can login, change
I'm trying to implement a basic object-oriented ANSI C runtime and using Objective-C as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.