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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:32:46+00:00 2026-05-18T20:32:46+00:00

I’m trying to parse a simple JSON file. I’m very new to javascript, JSON,

  • 0

I’m trying to parse a simple JSON file. I’m very new to javascript, JSON, and jquery. I’d like to extract the information in the JSON file so that I can plot it later using protovis. My JSON is well formed, and validates in the JSON lint.

I’m trying to accomplish this by parsing the JSON object’s responseText, like this:

var json = $.getJSON("week_13.json").responseText;
var week13 = $.parseJSON(json);

in the hope that week13 is something I can access. Just to note, I’m not trying to use a callback function in the $.getJSON call as I’d like to simply have access to the variables so that I can plot them later.

I’m using Chrome, and its console, to try and figure out what’s going on. In this code the variable json seems to be an empty string. However, if I write in the javascript console in Chrome:

var json = $.getJSON("week_13.json");

json is an XMLHttpRequest object and its responseText attribute is a big string containing my JSON.

var text = json.responseText;

is a nice string and then if I call jquery’s parser

var data = $.parseJSON(text);

then data is now the object I desired. However, if I copy and paste my original two lines into the console I have no luck, and if I use the expanded version froming the json, text and data variables in my original webpage it doesn’t work:

var json = $.getJSON("week_13.json");
var text = json.responseText;
var data = $.parseJSON(json);

In this case text is an empty string.

I’m totally confused. If anyone could let me know what I’m doing wrong and give some pointers as to how to make this work, I’d be very happy! Please let me know if any other information as to how I’m going about this is required to answer the question!

  • 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-18T20:32:46+00:00Added an answer on May 18, 2026 at 8:32 pm

    $.getJSON() is asynchronous. You need to supply a callback function to process the result. See the API doc for examples of callback functions.

    If you really need your call to be synchronous (it will block the browser while you wait for the result), then you can do this instead:

    var url = "week_13.json"
    var data = jQuery.parseJSON(
            jQuery.ajax({
                url: url, 
                async: false,
                dataType: 'json'
            }).responseText
        );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
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
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,

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.