I am sending some values to server side using jquery post. And as a response I am getting back string. Then I am taking that and converting into an object by using JSON.parse()...when I am looking at the console log i am seeing the object, which looks fine to me. Now when I am trying to loop through the object and trying to retrieve values I am not able to iterate through it. I cant figure out what am I missing here. I am sending the value on an on change event..so basically the for loop would run every time on change event
Here is my js
$(function(){
    var categoryChoiceVal = '';
    var x = [];
    var html = '';
    $('select').change(function() {
        categoryChoiceVal = $('.categoryChoice option:selected').text().replace(/ /g, '%20');
        $.post("ajax.php", { categoryChoiceVal:categoryChoiceVal},function(data) {
            x = $.parseJSON(data)
            console.log(x);
        }); 
        $.each(x, function(){
            html += this.address;
        });
        $('.dataContainer').html(html);
    });
});
here is the page where I am doing this. http://soumghosh.com/otherProjects/phpDataOperation/eventcCalendar/testOne.php
 
     
    