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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:17:40+00:00 2026-06-08T12:17:40+00:00

Here is the json returned by an ajax call: { StumbleUpon: 0, Reddit: 0,

  • 0

Here is the json returned by an ajax call:

{
    "StumbleUpon": 0,
    "Reddit": 0,
    "Facebook": {
        "commentsbox_count": 0,
        "click_count": 0,
        "total_count": 0,
        "comment_count": 0,
        "like_count": 0,
        "share_count": 0
    },
    "Delicious": 0,
    "GooglePlusOne": 1,
    "Buzz": 0,
    "Twitter": 1,
    "Diggs": 0,
    "Pinterest": 0,
    "LinkedIn": 1
}

I’m trying to process it in jquery but for some reason that i fail to understand, Facebook.total_count is undefined. I would expect otherwise since the console tells me the above json was received. Moreover, all others (data.Twitter, etc.) work. Here is my callback function where the error is produced. What am i doing wrong?

function(data){

                console.log(data);
//this line throws the error
                var fb = data.Facebook;
                var total = parseInt(data.Twitter + parseInt(fb.total_count) + data.GooglePlusOne + data.Pinterest + data.LinkedIn);
// rest of code.
}

See the code on jsFiddle.

  • 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-08T12:17:41+00:00Added an answer on June 8, 2026 at 12:17 pm

    Fundamentally, that code works — provided that data has already been deserialized. If it hasn’t, either…

    …add dataType: "JSON" to the ajax call:

    $.ajax({
        // ...
        dataType: "JSON",
        // ...
    });
    

    …or use $.parseJSON on the result.

    function(data) {
        if (typeof data === "string") {
            data = $.parseJSON(data);
        }
        // ...
    }
    

    Note: You don’t need to use parseInt on those numbers, they’re already numbers in the JSON and will be deserialized correctly.

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

Sidebar

Related Questions

I'm have trouble grabbing the response JSON data that's returned via AJAX call. Here
Here's my ajax call: $.ajax({ url: 'url-to-json', type: 'POST', dataType: 'json', cache: 'false', data:
I have the following JSON structure, being returned from an AJAX call (pseudo values)
I am creating some JSON data to be validated through an ajax call. Here's
Here's my client-side jQuery code: $.ajaxSetup ({ contentType: application/json, datatype: 'json' }); $.ajax({ type:
I have an AJAX controller action which returns JSON. The returned JSON is handled
I'm trying to send a Json array over using an AJAX call to a
Here's the JSON string returned from my action: [{Key:Likes,Value:1},{Key:Loves,Value:0},{Key:Dislikes,Value:0},{Key:Message,Value:Your vote has been changed}] Here's
As you can see I am retrieving JSON data from my ajax call but
Here's a simple ajax call wrapped in a method. MyNS.GetStringList = function (successCallback, failedCallback)

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.