Problem with $.each through json object

Problem with $.each through json object

Hello,

I am having the strangest problem with $.each through a json object.
 
Im trying to iterate through the object, Im obtaining addresses to pass to the google geocoder for mapping.

When I run the function all the red alerts are appearing then all the green are appearing.

It is supposed to display red and then green over and over. Does anyone see anything. Or do I not understand the $.each function.

  1. $.each($json.PDMOVE, function () {                                
  2. var nocntrs = 'No Containers = ' + $json.PDMOVE[x].SCCNTR;        
  3. var address = $json.PDMOVE[x].SCADR1 + ',' + $json.PDMOVE[x].SCCITY .....
  4. var name = $json.PDMOVE[x].SCNAME;                                
  5. alert(name + ' ' + address);                                      
  6. x = x + 1;                                                        
  7. var infowindow = new google.maps.InfoWindow({                     
  8.                  content: nocntrs                                 
  9. });                                                               
  10. geocoder.geocode({'address': address}, function(results, status) {
  11. alert(address + ' ' + status);                                    
  12. if (status == google.maps.GeocoderStatus.OK) {                    
  13. var loc   = results[0].geometry.location;                         
  14. var marker = new google.maps.Marker({                             
  15. position: loc,                                                    
  16. map: map,                                                         
  17. title: name                                                       
  18.                                                   
  19.     });  //Marker                                                   
  20.  google.maps.event.addListener(marker, 'click', function () {       
  21.  infowindow.open(map, marker);                                      
  22.     }); // AddListner                                               
  23.           }  //If status                                            
  24. });     // geocoder                                                 
  25.  });    // Each