Solved

access value in JSON return

Posted on 2013-11-05
2
246 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
[X]
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 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

Independent Software Vendors: 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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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

734 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