Solved

access value in JSON return

Posted on 2013-11-05
2
236 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
Comment Utility
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
Comment Utility
yup, was missing dataType: "json",
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Tag input html 4 35
HTML page and JavaScript 2 48
jQuery value within div undefined 3 17
Understanding Trigger in Jquery 10 24
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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…

762 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

7 Experts available now in Live!

Get 1:1 Help Now