1

I have one Json is back from ajax, the json is:

[{"id_caracteristica":"1","nombre":"Talla"},{"id_caracteristica":"2","nombre":"Color"}]

I need to save in two select the following information, id select is id_caracteristica value (1), and class select is name value (Talla)

1ºSelect id="1" class="Talla"
2ºSelect id="2" class="Color"

Solved, thanks to Gagan Deep, I put an alert as proof

...    
dataType: "json",
success: function(data){
  $.each(data, function(i, value) {
     alert(value.id_caracteristica+" "+value.nombre);
  }
...
3
  • 2
    why passing data[0] to the each function. just pass data instead and check value.id_caracteristica and value.nombre Commented Mar 8, 2019 at 11:28
  • Because I did not know how to do it correctly. And the answer you have given is completely correct and does exactly what I wanted, thank you very much. Commented Mar 8, 2019 at 11:46
  • 1
    Excellent work. I will post the comment as answer for future visitors. You may accept the answer if you like. You know reputation points. Commented Mar 8, 2019 at 11:48

1 Answer 1

1

Please pass data instead of data[0] to the $.each function. like below.

$.each(data, function(i, value) {
 alert(value.id_caracteristica+" "+value.nombre);
 }
Sign up to request clarification or add additional context in comments.

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.