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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:26:41+00:00 2026-05-21T07:26:41+00:00

gud day… i’m trying to write a program in javascript that uses .json. i

  • 0

gud day… i’m trying to write a program in javascript that uses .json. i already wrote one that is when i run the program, it will create a tab dynamically, using jquery, from my json data. it’s already a running program but my json data is in my javascript code. what im really confused about is how to do it using a separate .json file, .js and .html.

here is my running javascript code with my json in it

function CreateTab(o) {
  var str = '<ul>';
  for (var i = 0; i < o.length; i++) {        
    str += '<li><a href="#tab' + i + '">' + o[i].title +   '</a></li>';        
    }

    str += '</ul>';
    for (var i = 0; i < o.length; i++) {
    str += '<div id="tab' + i + '">' + o[i].desc + '</div>';
    }
 return str;
}

$(document).ready(function() {
 var json1 = [    
   {"title": "tab 1", "desc":"This is tab 1"},
   {"title": "tab 2", "desc":"This is tab 2"},
   {"title": "tab 2", "desc":"This is tab 2"}
  ];

$('#tabs').append(CreateTab(json1, "#tabs", true));    
       });

our instructor wanted us to use jQuery.getjson() only to get our .json file. he said that is what we are going to use if we are to connect soon to the server. i studied the sample from http://api.jquery.com/jQuery.getJSON/ and yes, it can display the

  • Singular sensation
  • Beady little eyes
  • Little birds pitch by my doorstep

but the problem is, i don’t how to do it if i will use

{"title": "tab 1", "desc":"This is tab 1"},
{"title": "tab 2", "desc":"This is tab 2"},
{"title": "tab 3", "desc":"This is tab 3"}

and much more in arrays of objects or object arrays….

i am new in using json file with javascript… so i really need help. thanks a lot.

  • 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-21T07:26:42+00:00Added an answer on May 21, 2026 at 7:26 am

    problem solved. here’s my javascript code:

    function CreateTab(o) {
    ...//the code is same as the question
    }
    
    $(document).ready( function() {  
    $.getJSON('tabfromjson.json',
      function(data) {        
         $('#tabs').append(CreateTab(data));
         $('#tabs').tabs();
      });
    });
    

    here’s my ‘tabfromjson.json’ file

    [
      { 
        "title": "tab 1",  
        "desc":"This is tab 1"
      },
    
      {
        "title": "tab 2",  
        "desc":"This is tab 2"
      },
    
      { 
        "title": "tab 3",  
        "desc":"Thistab 3"
      }
    ]
    

    if you are going to run this code, it will display three tabs with tab title and description in tabfromjson.json. you can add tab by just adding the data in the .json file.
    hope this helps for someone who is fresh and new to json, and to someone who want to know about this.

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

Sidebar

Related Questions

I'm trying to use gdb with emacs. The library that I'm trying to debug
I have a program that I'd like to debug with gdb via emacs. In
I'm trying to debug code in Emacs but when I try either M-x gdb
Hello gud fellas in my quest of learning spring, i created a web application
I put this in my .emacs file: (custom-set-variables '(gud-gdb-command-name gdb --annotate=1) '(large-file-warning-threshold nil) '(menu-bar-mode
I have gone through many related SO threads and got some basic info. Already
I'm trying to use rdebug with emacs and cygwin and I'm running into trouble.
I am trying to move from Emacs v22.3.1 to v23.1.1 and all was going
Can I debug a program running on a remote target to which I have
I'm running emacs 23.4 on OSX, obtained from emacsformacosx.com. I'm writing matlab code, using

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.