I'm trying to use Jquery to get the attributes of a Json variable. I made an ajax request with:
$.ajax({
url: 'myURL/' + id + '/' + date,
dataType: 'json',
}).done(function (data) {}
I put the url in the browser,and the returned data is like:
{"pico":0,"valle":1,"administrativas":"0"}
So, inside de done function how I get the value of pico variable for example?
asked Dec 23, 2015 at 20:02
Sredny M Casanova
5,10128 gold badges79 silver badges121 bronze badges
3 Answers 3
Just make it simple using:
$.ajax({
url: 'myURL/' + id + '/' + date,
dataType: 'json',
success: function (data) {
alert(data.pico);
}
});
answered Dec 23, 2015 at 20:14
Praveen Kumar Purushothaman
167k27 gold badges215 silver badges262 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Praveen Kumar Purushothaman
@SrednyMCasanova Enjoy the day!
:)$.ajax({
url: 'myURL/' + id + '/' + date,
dataType: 'json',
}).done(function (data) {
console.log(data.pico);
}
Comments
By accessing the property in the data response:
var data = {"pico":0,"valle":1,"administrativas":"0"};
console.log(data.pico);
Comments
lang-js