1

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

3 Answers 3

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

@SrednyMCasanova Enjoy the day! :)
1
$.ajax({ 
 url: 'myURL/' + id + '/' + date, 
 dataType: 'json', 
}).done(function (data) {
 console.log(data.pico);
}
answered Dec 23, 2015 at 20:07

Comments

1

By accessing the property in the data response:

var data = {"pico":0,"valle":1,"administrativas":"0"};
console.log(data.pico);
answered Dec 23, 2015 at 20:08

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.