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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:38:49+00:00 2026-06-13T22:38:49+00:00

I’m trying to populate a <span></span> element on the page load with jQuery. At

  • 0

I’m trying to populate a <span></span> element on the page load with jQuery.

At the moment the value that gets populated into the span is just an integer count.

Here I have named my span userCount:

<a href="#" class="">Users<span id = "userCount"></span></a>

I am trying to write the value of the span with no success.

$(document).ready(function () {
    $.post("Dashboard/UsersGet", {}, function (dataset) {
        var obj = jQuery.parseJSON(dataSet);
        var table = obj.Table;

        var countUsers;
        for (var i = 0, len = table.length; i < len; i++) {
            var array = table[i];
            if (array.Active == 1) {
                  var name = array.Name;
            }
            countUsers = i;
        }
        userCount.innerHTML = countUsers.toString();
    });
});
  • 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-13T22:38:52+00:00Added an answer on June 13, 2026 at 10:38 pm

    You don’t have any usercount variable. Use $(selector) to build a jquery object on which you can call functions like html.

     $('#userCount').html(countUsers);
    

    Note also that

    • you don’t need to convert your integer to a string manually.
    • if you don’t break from the loop, countUsers will always be table.length-1.
    • you have a typo : dataSet instead of dataset. Javascript is case sensitive.
    • you don’t need to parse the result of the request
    • you don’t need to pass empty data : jQuery.post checks the type of the provided parameters

    So, this is probably more what you need, supposing you do other things in the loop :

        $.post("Dashboard/UsersGet", function (dataset) {
            var table = dataset.Table;
            var countUsers = table.length; // -1 ?
            // for now, the following loop is useless
            for (var i=0, i<table.length; i++) { // really no need to optimize away the table.length
                var array = table[i];
                if (array.Active == 1) { // I hope array isn't an array...
                    var name = array.Name; // why ? This serves to nothing
                }
            }
            $('#userCount').html(countUsers);
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
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'm trying to select an H1 element which is the second-child in its group
I am currently running into a problem where an element is coming back from
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and

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.