0

Here is my json response:

[{"durum":"1"},{"durum":"2"},{"durum":"3"}]

My jquery function:

      $("select#durum").change(function(){
          $.post("autocomplete/ara_detay",{durum: $(this).val()}, function(j){
              var events = j; 
              var event = events[0];                  
              alert(j.length);
              alert(j.durum);
              alert(j.durum);
              var options = '';
              for (var i = 0; i < j.length; i++) {
                  options += '<option value="' + j[i].durum + '">' + j[i].durum + '</option>';
              }
              $("#durum").html(options);
          })      })

j.length alert says "43" and other alert messages says "undefined".

In which part am i doing wrong ?

1
  • 1
    have you checked in the console what was actually in j? and BTW, you can't use event as a variable name. Commented Feb 18, 2012 at 8:35

1 Answer 1

1

j is a string

var jsonParsed = JSON.parse(j);
alert(jsonParsed[0].durum);
alert(jsonParsed[1].durum);
alert(jsonParsed[2].durum);
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.