I have a problem, which I researched and thought how to do, but I could not solve. I have select
on the page that needs to be populated after a condition is satisfied . And after that, it needs to query the data relative to the option chosen in the select. Suppose that this select is to fill in the users name, and after it is filled in, a query must be made in the database with the data relative to that user. And that's where my problem was, even though I can fill out the select and bring in the data for the chosen user, every time the page is started, the script runs again and keeps checking every time . It's kind of a query loop that I can not seem to stop. How can I make only one query be done and then stop it so that the query is not repeated again ?
It's more a problem of logic than of syntax, which is why I have reduced the code itself.
<script>
$(document).ready(function () {
if (condicao) {
$.ajax({
// execução do ajax, aqui preencho o select
});
// aqui está o problema, ao preencher o select, é para submeter o form. Porém isso tem causado loop na consulta
}
})
</script>
<form method="post">
<select class='form-control' id='opcoes'>
</select>
</form>