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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:33:13+00:00 2026-05-24T18:33:13+00:00

This is a brand new concept to me, so I really need some help.

  • 0

This is a brand new concept to me, so I really need some help. I’m trying to populate all tags with the class “WorkstationCount” by using an ajax call to a web service. I have confirmed the webservice, as called below, is functioning and returning a proper integer. However, the HTML is never being changed. Currently with the code below I don’t receive any console errors either. I’m sure I’m doing this way wrong, but I tried 🙂

$('.WorkstationCount').html(function () {
    $.ajax({
        url: 'details.svc/getWorkstationCounts',
        type: 'GET',
        data: { 'packageid': $(this).attr('id') },
        dataType: 'json',
        success: function (count) {
            return count.d;
        },
        error: function (a, b, c) {
            $('.Toast').html('Error Retreiving Workstation Count!');
        }
    });
});

ATTEMPT TO CLARIFY

 <span class="WorkstationCount" id="1"></span>
 <span class="WorkstationCount" id="2"></span>
 <span class="WorkstationCount" id="3"></span>

So each span should have a different result… the ajax call is made using the element id, then it should modify the content of the span based on that result

  • 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-24T18:33:14+00:00Added an answer on May 24, 2026 at 6:33 pm

    Ah, after reading your comments I see your problem. You want to send along the id for each element n the data and make a separate ajax request for every WorkstationCount:

    $('.WorkstationCount').each(function(i, val){
        $.ajax({
            url: 'details.svc/getWorkstationCounts',
            type: 'GET',
            data: { 'packageid': this.id },
            dataType: 'json',
            success: (function(el){
                    return function (count) {
                        $(el).html(count.d);
                    };
                })(this),
            error: function (a, b, c) {
                $('.Toast').html('Error Retreiving Workstation Count!');
            }
        });
    });
    

    PS this.id is a faster way of writing $(this).attr('id'); since it doesn’t rely on a jQuery object and attr()

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

Sidebar

Related Questions

I'm brand new to python, and need some help understanding this code fragment: for
I'm getting this error message on all projects (including brand new empty templates) I'm
I'm starting up a brand new project using VS2010 and Silverlight 4. This is
I need a regex that matches this kind of strings: brand-new-car brand-new-car-1 brand-new-car-100 307
I'm brand new to this and I'm trying build a simple layout of divs.
This seems really simple but Im brand new to JavaScript. I have a link
I am brand new to AS3 and I am trying to move all of
Ok so this is a brand new snag I have run into. I am
i'm creating a brand new masterpage with VS2010 Beta 2 and I get this
Please allow me to preface this by saying I'm pretty much brand new to

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.