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?

3 Answers 3

1

Just make it simple using:

$.ajax({
    url: 'myURL/' + id + '/' + date, 
    dataType: 'json',
    success: function (data) {
        alert(data.pico);
    }
});
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);
}

Comments

1

By accessing the property in the data response:

var data = {"pico":0,"valle":1,"administrativas":"0"};
console.log(data.pico);

Comments

Your Answer

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.