Ajax Script does not work

1

I'm trying to fill a combo box of (cities) in the change of another combo box (states), and I tried to fill it up via AJAX, but the script I made is not running, if someone can help me, thank you right away

            <div class="row" onload=""?>
            <div class="input-field col s12 l6"> 

              <select name="Ped_estado" id ="estado" class = "browser-default"> 

                <?php
                    $connect = mysqli_connect('localhost:3306','root','');
                    $db = mysqli_select_db($connect,'ibico');
                    $sql_code = mysqli_query($connect,"SELECT Id, Nome, UF FROM Estado order by Nome ASC") or die("erro ao selecionar");
                    foreach ($sql_code as $estado) 
                    {
                    echo'<option value ="'.$estado['Id'].'">'.$estado['Nome'].'</option>';

                    }
                ?> 
           </select>
            </div>
          </div>                           
          <!-- <label for="estado">Estado</label> -->           
            <div class="input-field col s12 l6">
                <div class="row">
             <select name="Ped_municipio" id="municipios" class = "browser-default">

             <script>
                    $("#estado").on("change", function(){

                    var idEstado = $("#estado").val();
                    $.ajax({
                        url:'../ibico/php/carregaMunicipios.php';   
                        type: 'POST',
                        data:{id:idEstado},
                        beforeSend: function(){
                            $("#municipios").html("Carregando..");
                        },
                        success: function(data)
                        {
                            $("#municipios").html(data);
                        }
                        error: function(data)
                        {
                            $("#municipios").html("Houve um erro ao carregar !");
                        }
                    })

                    });
            </script>
    
asked by anonymous 07.06.2018 / 20:20

1 answer

0

You have a syntax error in your JavaScript code.

In your script, simply remove the semicolon from this line:

url: '../ibico/php/carregaMunicipios.php';

Getting, then:

url: '../ibico/php/carregaMunicipios.php'
    
07.06.2018 / 20:35