why States are not getting populated?

why States are not getting populated?

Hi,

I am using the following code to populate states based on country select using the php and jquery but everytime I select a country nothing is happening and my state dropdown is still empty.

where is the problem please? Happy New Year :)

Html:
  1. <tr>
  2.     <td valign="middle">Country</td>
  3.     <td valign="middle">:</td>
  4.     <td valign="middle">
  5.         <select name="cboCountry" id="cboCountry" style="width: 100%" required>
  6.             <option value="">[Country..]</option>
  7.             <?php
  8.                 $mysql_command = "CALL sp_populate_country()";
  9.                 $mysql_query = $mysql_connection->prepare($mysql_command);

  10.                 $mysql_query->execute();

  11.                 while($mysql_row = $mysql_query->fetch())
  12.                 {
  13.             ?>
  14.             <option value="<?php echo $mysql_row['country_code_alpha2']; ?>" <?php if ($mysql_row['country_code_alpha2'] == $company_country) { echo 'selected'; } ?>><?php echo $mysql_row['country_name']; ?></option>
  15.             <?php } ?>
  16.         </select>
  17.     </td>
  18. </tr>
  19. <tr>
  20.     <td valign="middle">State / City</td>
  21.     <td valign="middle">:</td>
  22.     <td valign="middle">
  23.         <select name="cboRegion" id="cboRegion" style="width: 100%">
  24.             <option value="">[State / City..]</option>
  25.         </select>
  26.     </td>
  27. </tr>


JQuery:
  1. <script type="text/javascript">
  2. $("#cboCountry").change(function() {
  3.         // var country = $(this).find("option:selected").val();
  4.         // alert(country);
  5.         $.ajax({
  6.         url : "populate_region.php?id=" + $(this).val(),
  7.         type: 'GET',
  8.         dataType:'json',
  9.         cache: false,
  10.         success : function(data) {
  11.             if (data.success) {
  12.                 $("#cboRegion").html(data.options);
  13.             }
  14.             else {
  15.                 // Handle error
  16.             }
  17.         }
  18.     });
  19. });
  20. </script>



populate_region.php
  1. <?php
  2.     include('../includes/php_header.php');
  3.     include($_SESSION["absolute_path"] . '/includes/connect2db.php');

  4.     $country_code = $_GET['id'];
  5.     
  6.     if (!isset($country_code)) $reponse = array('success' => FALSE);
  7.     else
  8.     {
  9.         $mysql_command = "CALL sp_populate_region()";
  10.         $mysql_query = $mysql_connection->prepare($mysql_command);
  11.         $mysql_query->bindParam(':param_country_code', $country_code, PDO::PARAM_STR);

  12.         $mysql_query->execute();

  13.         while($mysql_row = $mysql_query->fetch())
  14.         {
  15.             $options .= '<option value="'. $mysql_row['region_id'] .'">'. $mysql_row['region_name'] .'</option>';
  16.         }

  17.         $response = array
  18.         (
  19.             'success' => TRUE,
  20.             'options' => $options
  21.         );

  22.         header('Content-Type: application/json');
  23.         echo json_encode($response);
  24.         
  25.         // include($_SESSION["absolute_path"] . '/includes/php_footer.php');
  26.     }
  27. ?>