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 6756627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:32:51+00:00 2026-05-26T13:32:51+00:00

I’m doing a login system with facebook, based on AJAX, and I’m having a

  • 0

I’m doing a login system with facebook, based on AJAX, and I’m having a little problem with that…

I have a form page with Facebook Login Button that is imported the first time via PHP and then is called via AJAX whenever someone click on a button, to change content if a login was sucessfull or to show the same form if not sucessfull.

<form method="post" id="regist_form" enctype="application/x-www-form-urlencoded" action="asd.php">
<table>
<tr>
    <?php echo $this->form->username; ?>
</tr>
<tr>
    <?php echo $this->form->password; ?>
</tr>
<tr>
<td><br/><script type="text/javascript">
    document.write('<div class="fb-login-button" id="face_login" onlogin="loginAsFacebook()" scope="email,user_activities,publish_stream">Facebook</div>');
</script>
</td>
<td><br/>
    <?php echo $this->form->login_form_csrf.$this->form->login_user; ?>
</td>
</tr>
</table>
</form>

The problem is that when I call this form page via AJAX, the page is somehow refreshed and interrupted at the middle. However, when it is loaded via PHP, it loads OK…

I tried that without the Facebook Login button and it works OK too…

After some tries, I find out that the problem is related to document.write…
I changed it to:

$(document).ready(function(){
    $('#face_gen').append('<div class="fb-login-button" class="face_login" onlogin="loginAsFacebook()" scope="email,user_activities,publish_stream">Facebook</div>');
    FB.XFBML.parse(document.getElementById('face_login'));
});

Now it loads ok via AJAX but without the rendering of the Facebook’s button…

Could it be because I’ve the facebook’s all script loaded on the parent page?

<script src="//connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<script type="text/javascript">
    FB.init({
        appId      : 'xxxxxxxxxxxxxxx', // App ID
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        oauth      : true, // enable OAuth 2.0
        xfbml      : true, // parse XFBML
        fbml5        : true
    });
</script>

I tried using this but it didn’t work too:

$("#user_reg_login").load("logincontent/logincontent/",function(){
    FB.XFBML.parse(document.getElementById('face_login'));
});

What am I missing now to render the button properly?

  • 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-05-26T13:32:51+00:00Added an answer on May 26, 2026 at 1:32 pm

    Ok, I find out how to put it working.

    Here’s the solution:

    <form method="post" id="regist_form" enctype="application/x-www-form-urlencoded" action="">
    <table>
        <tr>
            <?php echo $this->form->username; ?>
        </tr>
        <tr>
            <?php echo $this->form->password; ?>
        </tr>
        <tr>
            <td id="face_gen"><br/><script type="text/javascript">
                $(document).ready(function(){
                    $('#face_gen').append('<div class="fb-login-button" class="face_login" onlogin="loginAsFacebook()" scope="email,user_activities,publish_stream">Facebook</div>');
                    FB.XFBML.parse(document.getElementById('face_login'));
                });
            </script>
    
            </td>
            <td><br/>
                <?php echo $this->form->login_form_csrf.$this->form->login_user; ?>
            </td>
        </tr>
    </table>
    </form>
    

    I forgot to say that I’m using Zend Framework.

    Now it renders the button well after AJAX call =D.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has

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.