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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:38:33+00:00 2026-05-26T04:38:33+00:00

I’ve been looking around for a similar question, but I couldn’t find one. I’m

  • 0

I’ve been looking around for a similar question, but I couldn’t find one.
I’m trying to push the number of twitter/facebook/rss followers to a <span>....</span> in my sidebar.

To get the numbers I use some php scripts. In a separate file I have the javascript and in my sidebar.php file I’ve got the <span>....</span>.
I’ve tried to debug everything but I can’t find my mistake.

In the sidebar I use:

<div id="social-bar">

                    <ul>
                        <li class="rss-count"><a href="http://feeds.feedburner.com/dewereldverzamelaar"><span>..........</span></a></li>
                        <li class="twitter-count"><a href="http://twitter.com/deverzamelaar"><span>..........</span></a></li>
                        <li class="facebook-count"><a href="http://www.facebook.com/dewereldverzamelaar"><span>..........</span></a></li>
                    </ul>

                <!--END #social-bar-->
                </div>

My php files to get my twitter followers (for example) looks like this:

<?php
$screenName = 'deverzamelaar';
$getData = 'followers_count';

$xml = file_get_contents('http://twitter.com/users/show.xml?screen_name=' . $screenName);

if(preg_match('/' . $getData . '>(.*)</', $xml, $count) !=0)
echo "$count[1]";   
?>

Last you have the jQuery script:

var count = 0;

jQuery('.rss-count span').load('http://www.dewereldverzamelaar.com/wp-content/developer/themes/gridlocked/includes/update-rss.php', function() {
        count++;
        tz_showSocial(count);

});
jQuery('.twitter-count span').load('http://www.dewereldverzamelaar.com/wp-content/developer/themes/gridlocked/includes/update-twitter.php', function() {
        count++;
        tz_showSocial(count);
});
jQuery('.facebook-count span').load('http://www.dewereldverzamelaar.com/wp-content/developer/themes/gridlocked/includes/update-facebook.php', function() {
        count++;
        tz_showSocial(count);
});

function tz_showSocial(count) {
if(count == 3)
    jQuery('#social-bar').fadeIn(200);
}

I know the php scripts work because they echo the right amount of followers. I think the jQuery also works because the counter reaches 3 and the div social-bar shows up. But it won’t show the amount of followers, it keeps showing the ….. .
I’m not a php/html or jQuery specialist. I’ve grabbed some snippets and tried to build something of it.
How come the echo doesn’t go to the <span></span>? I hope someone can explain and help me.

Greetings
Jonas Smets

Here the edited version, remember its already in a “jQuery(document).ready(function() {” because there are a lot of other scripts (from the wordpress theme) being loaded:

var count, loadCallback;

count = 0;
loadCallback = function(response, status, request) {
  // Since you use the same code in all the callbacks, you might as well
  // only declare the function once. Since we're doing that, we might as
  // well merge tz_showSocial into here as well...
  if (request.status != 200) {
    alert('Oh no! Something went wrong with the update! (HTTP '+request.status+')');
  }
  count++;
  if (count > 2) {
    jQuery('#social-bar').fadeIn(200);
  }
};

// As Dvir Azulay correctly points out, you should execute the AJAX calls
// in the ready event

  jQuery('.rss-count span').load('/includes/update-rss.php', loadCallback);
  jQuery('.twitter-count span').load('/includes/update-twitter.php', loadCallback);
  jQuery('.facebook-count span').load('/includes/update-facebook.php', loadCallback);

With this version of the code there is definitely something happening: http://www.developer.dewereldverzamelaar.net
The page loads fine but goes blank? It has something to do with the jQuery script, if I take the script out the page loads fine.

If you need any extra info, please let me know.
Jonas Smets

//////////////////////////////////////////////////
Still not working, this is what I have right now:

    /* here are some variables I've added for my script: */
    var count, loadCallback;

    count = 0;
        /*-----------------------------------------------------------------------------------

            Custom JS - All front-end jQuery

        -----------------------------------------------------------------------------------*/


        /*-----------------------------------------------------------------------------------*/
        /*  Remove JavaScript fallback class
        /*-----------------------------------------------------------------------------------*/

        jQuery('#container').removeClass('js-disabled');

        /*-----------------------------------------------------------------------------------*/
        /*  Let's get ready!
        /*-----------------------------------------------------------------------------------*/

        jQuery(document).ready(function() {
    /* here you get some other scripts the theme uses */

    /* here my script start */
    loadCallback = function(response, status, request) {
      // Since you use the same code in all the callbacks, you might as well
      // only declare the function once. Since we're doing that, we might as
      // well merge tz_showSocial into here as well...
      if (request.status != 200) {
        alert('Oh no! Something went wrong with the update! (HTTP '+request.status+')');
      }
      count++;
      if (count > 2) {
        jQuery('#social-bar').fadeIn(200);
      }
    };

    // As Dvir Azulay correctly points out, you should execute the AJAX calls
    // in the ready event

      jQuery('.rss-count span').load('http://developer.dewereldverzamelaar.net/wp-content/themes/gridlocked/includes/update-rss.php', loadCallback);
  jQuery('.twitter-count span').load('http://developer.dewereldverzamelaar.net/wp-content/themes/gridlocked/includes/update-twitter.php', loadCallback);
  jQuery('.facebook-count span').load('http://developer.dewereldverzamelaar.net/wp-content/themes/gridlocked/includes/update-facebook.php', loadCallback);


    /* again one other script the theme uses */
    /* at the end this script closes the document.ready  function closes */

Right now the page still reloads to a blank one. When I take out my jQuery code everything works fine again. I have no idea what I could do to make it work.

Jonas

Oke, for some reason its working now. Don’t know what i’ve changed. For people having the same question, this is the jQuery code that works, I didn’t change my php and html code, they were fine from the start:

/* Some Variables outside the document.ready function */
var count, loadCallback;
count = 0;
/*-----------------------------------------------------------------------------------*/
/*  Let's get ready!
/*-----------------------------------------------------------------------------------*/

jQuery(document).ready(function() {


/*-----------------------------------------------------------------------------------*/
/*  Social Count Script
/*-----------------------------------------------------------------------------------*/


loadCallback = function(response, status, request) {
  // Since you use the same code in all the callbacks, you might as well
  // only declare the function once. Since we're doing that, we might as
  // well merge tz_showSocial into here as well...
  if (request.status != 200) {
    alert('Oh no! Something went wrong with the update! (HTTP '+request.status+')');
  }
  count++;
  if (count > 2) {
    jQuery('#social-bar').fadeIn(200);
  }
};

// As Dvir Azulay correctly points out, you should execute the AJAX calls
// in the ready event

  jQuery('.rss-count span').load('http://developer.dewereldverzamelaar.net/wp-content/themes/gridlocked/includes/update-feedburner.php', loadCallback);
  jQuery('.twitter-count span').load('http://developer.dewereldverzamelaar.net/wp-content/themes/gridlocked/includes/update-twitter.php', loadCallback);
  jQuery('.facebook-count span').load('http://developer.dewereldverzamelaar.net/wp-content/themes/gridlocked/includes/update-facebook.php', loadCallback);

/* Some other scripts go here, at the end the document.ready function is closed. */

Thnx all.
Jonas Smets

  • 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-26T04:38:34+00:00Added an answer on May 26, 2026 at 4:38 am
    1. Are you sure those URL’s are correct (in the JS code)? I can’t load them…
    2. Is the page you are trying to run the JS code also served from www.dewereldverzamelaar.com? Because if not, it absolutely will not work, because of the same origin policy.

    I think the best way to work out what the problem is would be to add some error handling in your callback function. This is fairly simple, since jQuery will helpfully pass the XMLHTTPRequest object into the callback as the third parameter.

    For example, here is how I would write that code…

    var count, loadCallback;
    
    count = 0;
    loadCallback = function(response, status, request) {
      // Since you use the same code in all the callbacks, you might as well
      // only declare the function once. Since we're doing that, we might as
      // well merge tz_showSocial into here as well...
      if (request.status != 200) {
        alert('Oh no! Something went wrong with the update! (HTTP '+request.status+')');
      }
      count++;
      if (count > 2) {
        jQuery('#social-bar').fadeIn(200);
      }
    };
    
    // As Dvir Azulay correctly points out, you should execute the AJAX calls
    // in the ready event
    $(document).ready(function() {
      $('.rss-count span').load('http://www.dewereldverzamelaar.com/wp-content/developer/themes/gridlocked/includes/update-rss.php', loadCallback);
      $('.twitter-count span').load('http://www.dewereldverzamelaar.com/wp-content/developer/themes/gridlocked/includes/update-twitter.php', loadCallback);
      $('.facebook-count span').load('http://www.dewereldverzamelaar.com/wp-content/developer/themes/gridlocked/includes/update-facebook.php', loadCallback);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:

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.