Solved

access value in JSON return

Posted on 2013-11-05
2
242 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
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…

772 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