1
I am trying to fill a combo box (cities) in the change of another combo box (states), and I tried to fill this out via AJAX, but the script I made is not running, if anyone can help me, I thank you from now
<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>
Which error is triggered?
– Artur Trapp
Syntaxerror: Unexpected token;
– Reignomo
url:'../ibico/php/carregaMunicipios.php';
change the semicolon at the end of that line by a comma– Artur Trapp
exact as Artur quoted.
– Michel Simões
That’s right, vlw :D
– Reignomo
People now accused other error Uncaught Syntaxerror: Unexpected Identifier
– Reignomo