Reputation: 5063
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?
Upvotes: 1
Views: 36
Reputation: 167250
Just make it simple using:
$.ajax({
url: 'myURL/' + id + '/' + date,
dataType: 'json',
success: function (data) {
alert(data.pico);
}
});
Upvotes: 1
Reputation: 313
By accessing the property in the data response:
var data = {"pico":0,"valle":1,"administrativas":"0"};
console.log(data.pico);
Upvotes: 1
Reputation: 144
$.ajax({
url: 'myURL/' + id + '/' + date,
dataType: 'json',
}).done(function (data) {
console.log(data.pico);
}
Upvotes: 1