Solved

access value in JSON return

Posted on 2013-11-05
2
238 Views
Last Modified: 2013-11-05
Using the following


	$.ajax( {
			url: url,
			type:'GET',
			//success: function(data) { displayWalkScores(data); },
			success: function(data) {
				console.log(data);
				$("#dataInfo").html(data);
				$("#myWalkScore").html(data.walkscore);
				},
			error: function(){ displayWalkScores(""); }
			}
		);

Open in new window


I get the following when I put data into #dataInfo, but I am having issues putting just the walkscore into #myWalkScore.  How do I access this value by itself?

{ "status": 1 , "walkscore": 97 , "description": "Walker's Paradise" , "updated": "2013-06-17 20:23:54.900400" , "logo_url": "http://www2.walkscore.com/images/api-logo.gif" , "more_info_icon": "http://www2.walkscore.com/images/api-more-info.gif" , "more_info_link": "http://www.walkscore.com/how-it-works.shtml" , "ws_link": "http://www.walkscore.com/score/1119-8th-Avenue-.num.42-Seattle-WA-98101/lat=47.6085/lng=-122.3295/?utm_source=iastate.edu&utm_medium=ws_api&utm_campaign=ws_api" , "snapped_lat": 47.6085 , "snapped_lon": -122.3295 }
0
Comment
Question by:lvmllc
2 Comments
 
LVL 17

Accepted Solution

by:
OmniUnlimited earned 250 total points
ID: 39624343
Try specifying the datatype:

$.ajax( {
			url: url,
			type:'GET',
		        dataType: "json",
			//success: function(data) { displayWalkScores(data); },
			success: function(data) {
				console.log(data);
				$("#dataInfo").html(data);
				$("#myWalkScore").html(data.walkscore);
				},
			error: function(){ displayWalkScores(""); }
			}
		); 

Open in new window

0
 

Author Closing Comment

by:lvmllc
ID: 39625446
yup, was missing dataType: "json",
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now