[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


JSON data From Census

Posted on 2013-11-01
Medium Priority
Last Modified: 2013-11-02
I am working with the US Census API and am curious if I am doing this right or if there is a better way to do this.
I am using CORS but could do this with jsonp

The urls and output are


["672591","North Dakota","38"]]


["672591","North Dakota","38"]])

In the case of the first URL I have the following code


Open in new window

The alert produces a string
P0010001,NAME,state,3046355,Iowa,19,672591,North Dakota,38

and the console prints Iowa

My first question is why does Alert make a string and not display object object?

I think I am OK using this jquery as I am able to access the values, but would like to know if any of you experts have concerns about this method.
Question by:lvmllc
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39617898
The reason is your alert is asking for all the data and what you are sending to the console is the 2nd item in the 2nd row of data.  Array's are zero based.  If you used 0,0 instead, you would have seen, P0010001

Author Comment

ID: 39618207
I understand the 0,0 base. I was just surprised that an alert without specifying the array location returns the full data string.

Any comments on if this is the best approach to grabbing this JSON data?
LVL 54

Accepted Solution

Scott Fell,  EE MVE earned 1000 total points
ID: 39618238
If your "get" or "post" returns 1 or 10,000 records, they all would show up when you try and output "data".     From there, you would not typically use "data" to display your the output unless for instance the data being returned was not json and instead a short bit of text or  html.  If you do have 10,000 rows of data in json/jsonp it is all on the client machine and you can now access the data many multiple times by calling just the portion of data you need without making more trips to the server.  

10,000 rows of data is more than likely going to be too much and there would be a long initial lag time for all that data to load.   Let's say you do have 10,000 total rows of data, you would probably want to make your ajax call return just several hundred rows at a time.  Then on your actual web page, you may display just 10 rows of data at a time.  You would set up some type of paging that tracks where the user is and at the appropriate spot, call additional data to load similar to this example http://datatables.net/release-datatables/examples/server_side/jsonp.html
LVL 44

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 400 total points
ID: 39618803
My first question is why does Alert make a string and not display object object?

Because your returned data is an array - not an object!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question