Problems loading a Select

0

For some time now I have been presented with this problem in a registration form that I am doing, I am trying to fill several select dependent of each example: Country-> State-> city I'm doing with Jquery

$(document).ready(function(){
            $("#list_pais").change(function () { 
                $('#list_city').find('option').remove().end().append('<option value="0">Seleccione...</option>').val('0');  
                $("#list_pais option:selected").each(function () {
                    id_pais = $(this).val();
                    $.get("includes/Get.php?modo=selectEstado", { id_pais: id_pais }, function(data){                         
                        $("#list_edo").html(data);
                    });            
                });
            })
        });

$(document).ready(function(){
$("#list_edo").change(function () {
    $("#list_edo option:selected").each(function () {
        id_edo = $(this).val();
            $.get("includes/Get.php?modo=selectCity", { id_edo: id_edo }, function(data){
            $("#list_city").html(data);
        });            
    });
})
});

When I change the select of the identifier #list_pais to fill the state select the one that has identifier #list_city throws me this error: [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience . For more help, check link .

When I look at the browser console to see what the city select is bringing me, I find that the header of the document inside the Select is loading inside the Select "that's crazy", and the most curious part of the case is I'm using the same function for other select in another document and it works perfectly for me.

here is the extract of the html document where the form is

<?php
                $sql ="SELECT * FROM paises";
                $datos = $db->consultaRetorno($sql);            
                ?>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="pais">Pais</label>
                            <select name="list_pais" id="list_pais" >
                                <option value="0">Seleccione...</option>
                                 <?php while ($row = $datos->fetch_assoc()) { ?>                         
                                 <option value="<?php echo $row['id_pais']?>"><?php echo $row['pais']?></option>                <?php }?>
                            </select>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="edo">Estado</label>
                            <select name="list_edo" id="list_edo">
                                <option value="0">Seleccione...</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="city">Ciudad</label>
                            <select name="list_city" id="list_city">
                                <option value="0">Seleccione...</option>
                            </select>
                        </div>
                    </div>                        
                </div>

here the extract in the so-called get.php where I refer to the jquery function

case 'selectEstado':
    $id_pais = $_GET['id_pais'];
    $queryEdo = "SELECT id_estado,estados FROM estados WHERE pais_id='$id_pais'ORDER BY estados";
    $datos = $db->consultaRetorno($queryEdo);
    $html = "<option value='0'>Seleccione...</option>";
    while ($rowEdo = $datos->fetch_assoc()) {
        $html="<option value='".$rowEdo['id_estado']."'>".$rowEdo['estados']."</option>";
        echo $html;
    }

    break;

here is the excerpt where I see the city

case 'selectCity':
    $id_edo = $_GET['id_edo'];

    $queryCity = "SELECT id_ciudad,ciudad FROM ciudades WHERE estado_id = '$id_edo'ORDER BY ciudad";
    $datos = $db->consultaRetorno($queryCity);
    $html = "<option value='0'>Seleccione...</option>";
    while ($rowCity = $datos->fetch_assoc()) {
        $html="<option value='".$rowCity['id_ciudad']."'>".$rowCity['ciudad']."</option>";
        echo $html;
    }
    break;

There are times when the script works and there are times that I do not, I do not know if I'm doing something wrong, I really need help because I'm behind in the project I'm doing and it does not let me get ahead as this is the phase of user registration

    
asked by Diego Fajardo 30.01.2018 в 15:31
source

0 answers