how to iterate array in json : how to iterate array in json



	 
    $(document).ready(function(){       
        $('#wardno').change(function(){ //any select change on the dropdown with id country trigger this code         
            $("#wardname > option").remove(); //first of all clear select items
            var ward_id = $('#wardno').val(); 
			// here we are taking country id of the selected one.
		    $.ajax({
            type: "POST",
		 	cache: false,
			url:"get_wardname/"+ward_id, //here we are calling our user controller and get_cities method with the country_id
			success: function(cities) //we're calling the response json array 'cities'
                { 
				
                  try{	
				 
 					$.each(cities,function(id,city) //here we're doing a foeach loop round each city with id as the key and city as the value
					
					{
						
						
						
					 var opt = $('<option />'); // here we're creating a new select option with for each city
 					opt.val(id[0]);
 					opt.text(id[1]);
 					$('#wardname').append(opt);
					 var opt1 = $('<option />'); // here we're creating a new select option with for each city
 					opt1.val(city[0]);
 					opt1.text(city[1]);
 					$('#koottaymaname').append(opt1);
					});
					 //here we will append these new select options to a dropdown with the id 'cities'
				
					}catch(e) {		
					alert(e);
					}		
					},
		      error: function (jqXHR, textStatus, errorThrown) {
            alert("jqXHR: " + jqXHR.status + "\ntextStatus: " + textStatus + "\nerrorThrown: " + errorThrown);
        		}
                 
            });
             
        });
    });
    // ]]>
</script>


The output from the code is
[{"1":"St. Sebastian"},{"1":"kudumbakoottayma1","2":"kudumbakoottayma2"}]

How to iterate into two different drop down list
