I'm doing a select in php using a variable that comes from ajax, the problem is that the php is trying to query before receiving the ajax value, this generates an error on the page and the routine is broken in the middle
FOLLOW THE CONSOLE ERROR LOG:
<div class='modal fade' id='modalVisualizarComponentes' tabindex='-1' role='dialog' aria-labelledby='myModal'>
<div class='modal-dialog modal-lg' role='document' style='height:80% !important; width:100% !important;'>
<div class='modal-content'><div class='modal-header'><button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button><h4 class='modal-title' id='myModalLabel'>Componentes</h4></div>
<div class='modal-body'><table class='table table-striped'><tr><th>Sequencial</th><th>Código</th><th>Nome</th><th>Entrada</th><th>Saída</th><th>Quantidade F</th><th>Quantidade M</th><th>Quantidade G</th><th>Quantidade GG</th><th>Total</th><tbody><br />
// HERE IS WHERE I NEED TO CONSULT THE FIELD THAT I NEED TO BE DOWN THERE.
Warning : mysqli_fetch_array () expects parameter 1 to be mysqli_result, boolean given in C: \ xampp \ htdocs \ Maintenance \ administrator.php on line 265
Exit
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"> </script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<script type="text/javascript">
function validaCampoAparelho()
{
if (document.aparelho.labelAparelho.value=="")
{
alert("O campo aparelho está em branco!!");
return;
}
}
$("#visualizarAparelhos").submit(function (e) {
//e.preventDefault();
var dados = $("#visualizarAparelhos").serialize();
$.ajax({
type: "POST",
url: "administrador.php",
data: {selectComponentes: dados}
}).done(function (data) {
console.log(data);
//$("#modalVisualizarComponentes").show();
});
return false;
});
// THIS IS THE INFORMATION I NEED TO CONSULT
selectComponentes=9