Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

access value in JSON return

Posted on 2013-11-05
2
Medium Priority
?
254 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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

972 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