0
I am unable to execute the function when changing the value of select, follow the code below.
index php.
<div class="input-group m-2">
<!-- Combo Estados !-->
<div class="input-group-prepend ml-3">
<label class="input-group-text" for="cmb_estado_site">Estado</label>
</div>
<select class="custom-select" id="cmb_estado_site"></select>
<!-- Combo Cidade !-->
<div class="input-group-prepend ml-3">
<label class="input-group-text" for="cmb_cidade_site">Cidade</label>
</div>
<select class="custom-select" id="cmb_cidade_site">
<option selected="TODAS" >TODAS</option>
</select>
</div>
Function.js
$(document).ready(function() {
$('#cmb_estado_site').click(function () {
var estado = $('#cmb_estado_site').val();
$.post('/lib/php/function.php',{action:'load-cidade', estado:estado},function (data) {
$('#cmb_operadora_site').html(data);
});
});
}
the return of the post request is correct, tested by Postman, by debug is not entering the function, someone could inform me what I am doing wrong?
Shows what the $.post response format looks like, (which appears if I give you a console.log(date) within the method
done
) so that we can build a more complete answer.– José Guilherme Oliveira
I was able to solve, the error was in the way I loaded the page, I was taking from another file the code of these combos, this after having already loaded the script, so I think I was not triggering the event, but thanks for the attention.
– Baagrel