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

  • Home
  • SEARCH
  • 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 6325737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:57:09+00:00 2026-05-24T16:57:09+00:00

What I have.. $.getJSON(‘ui-DashboardWidgetsGet.php’, function(msg) { alert(msg); if(msg.error == yes){console.log(‘Error Found: ‘+ msg.errorMsg);} else

  • 0

What I have..

$.getJSON('ui-DashboardWidgetsGet.php', function(msg)
    {
        alert(msg);
        if(msg.error == "yes"){console.log('Error Found: '+ msg.errorMsg);}
        else
        {
            ztsDashboardJSON = msg;
        }
    });
var ztsDashboardJSONCount = ztsDashboardJSON.widgets[0].length;

which dumps

{ "widgets": [{ "column1": [ {"weight": 1, "bID": 1, "hideMe": false, "collapse": false, "titleOf": "Test 1", "colorOf": "color-yellow", "theFunction": "functionName"}, {"weight": 2, "bID": 2, "hideMe": false, "collapse": false, "titleOf": "Test 2", "colorOf": "color-green", "theFunction": "functionName"}, {"weight": 3, "bID": 3, "hideMe": false, "collapse": false, "titleOf": "Test 3", "colorOf": "color-blue", "theFunction": "functionName"} ], "column2": [ {"weight": 1, "bID": 4, "hideMe": false, "collapse": false, "titleOf": "Test 4", "colorOf": "color-white", "theFunction": "functionName"}, {"weight": 2, "bID": 5, "hideMe": false, "collapse": false, "titleOf": "Test 5", "colorOf": "color-red", "theFunction": "functionName"}, {"weight": 3, "bID": 6, "hideMe": false, "collapse": false, "titleOf": "Test 6", "colorOf": "color-orange", "theFunction": "functionName"} ], "column3": [ {"weight": 1, "bID": 7, "hideMe": false, "collapse": false, "titleOf": "Test 7", "colorOf": "color-white", "theFunction": "functionName"}, {"weight": 2, "bID": 8, "hideMe": false, "collapse": false, "titleOf": "Test 8", "colorOf": "color-green", "theFunction": "functionName"}, {"weight": 3, "bID": 9, "hideMe": false, "collapse": false, "titleOf": "Test 9", "colorOf": "color-blue", "theFunction": "functionName"} ] }]}

Which is valid as per http://jsonlint.com/

It requests the php which echo’s that out from a db, it echo’s just that, nothing else. Yet I am trying to work with the result in the JavaScript there after and it doesn’t seem to be supplying me what I want..

my error:

ztsDashboardJSON.widgets is undefined [Break On This Error] var
ztsDashboardJSONCount = ztsDashboardJSON.widgets[0].length;

  • 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-24T16:57:11+00:00Added an answer on May 24, 2026 at 4:57 pm

    You need:

    var ztsDashboardJSONCount = ztsDashboardJSON.widgets.length; // length is 1
    

    since “widgets” is a key mapped to an array of objects.

    If you’re trying to get the length of a column, you can do:

    ztsDashboardJSON.widgets[0].column1.length; // length is 3
    

    Demo here.

    To traverse your object to make use of all the widgets, columns and column values, you can do this:

    var widgets = ztsDashboardJSON.widgets;
    
    $.each(widgets, function(i, val) {
        console.log("widget number" + i);
        $.each(val, function(i2, val2) {
            console.log(i2);
            $.each(val2, function(i3, val3) {
                console.log(val3.weight);
                console.log(val3.bID);
                console.log(val3.hideMe);
                console.log(val3.titleOf);
                console.log(val3.colorOf);
                console.log(val3.theFunction);
            });
        });
    });
    

    Demo here.

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

Sidebar

Related Questions

I have a simple getJson request: $.getJSON('JsonTest', function(o) { alert(o.Test); }); It works, but
Inside of a jQuery plugin I made I have: $.getJSON(base_url,{ agenda_id:defaults.id, action:defaults.action+defaults.type, output:defaults.output },function(json){
I have this code: $.getJSON(Featured/getEvents, function(data){ $.each(data.events, function(i,event){ var title = event.title.substr(0,20); $(#title-+i).text(Text); if
I have a problem with Jquery function getJSON, the action url does not trigger
if i have a href getJSON is working fine as expected (getting alert message
I have the following javascript: $.getJSON('/calculate_quote/' + moulding_1_id, function(data) { moulding_1_cost = data.moulding.cost; moulding_1_width
I have some PHP code that outputs a JSON array when $.getJSON is called:
I have an odd problem with the following: function loadTextbox(jsonUrl,divId){ $.getJSON(jsonUrl, function(json) { $('#'
I have a webservice returning jsonp format. here's the code: $(document).ready(function(){ $.getJSON(http://api.tubeupdates.com/?method=get.status&lines=central,victoria&return=name&jsonp=?, function (result){
I have some <li> items appended by jQuery $.getJSON function. for example: <ul> <li><input

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.