0
I have a function ajaxForm
that searches some data in the database and should return the HTML result in a div. The problem is that when inspecting the page the return is correct, but in div
appears only the number "0". Someone can help?
Form:
<form class="form-inline" method="POST" id="pesquisa" action="">
<fieldset>
<div class="col-sm-8">
<div class="form-group">
<input type="btn" id="movimenta" name="movimenta" class="form-control" aria-describedby="basic-addon2">
<select class="form-control" id="galpao" name="local">
<option>Selecione o local</option>
<?php
while($linha = mysqli_fetch_assoc($galpao)){?>
<option value="<?php echo $linha['id']; ?>"><?php echo $linha['nome']; ?></option>
<?php }?>
</select>
<input type="submit" class="form-control" id="pesquisaGalpao" value="Pesquisar">
</div>
</div>
</fieldset>
</form>
Div:
<div class="info">0</div>
Ajax code:
$(document).ready(function(){
$('#pesquisa').ajaxForm({
target:'.info',
url:'sql.php',
success: function(msg){
$(".info").html(msg);
}
});
});
Return shown when inspecting the page:
<section class="panel col-lg-12">
<table class="table table-striped table-bordered table-hover table-checkable order-column" id="">
<thead>
<tr>
<th> Código</th>
<th> Descrição </th>`
What the form sends:
movimenta:grampo
local:11
What returns from the sql.php page:
Código Descrição Galpão Rua Coluna Altura Qtde Lote Validade Movimentar
12345678901234 GRAMPO Armazem 01 1 2 0 15
Is there a better way to detail what’s going on? If you inspect the element, what exactly is the content that appears? 0 appears on the rendered page?
– Woss
Do you have any other element with that same class? Have you tried replacing it with a
#id
?– Leonardo Pessoa
the Id
#pesquisa
is there? can put the entire code so that it is possible to better understand the problem?– Alisson Steffens
I updated the question with the form code. I already replaced it with id and the same problem happens.
– Eduardo
Responding to Anderson and Leornardo, yes, it is on the rendered page that 0 appears and I have no other element with this class. Also already replaced by id and the same problem happens.
– Eduardo
Do not use the question to answer the problem. The answer field already has this purpose, so use it.
– Woss
@Eduardo Again I will say: [en.so] is not a forum, so DO NOT use the question area to publish the answer. Make the [tour] as soon as possible and learn to use the site correctly to avoid any embarrassment.
– Woss
Thanks @Andersoncarloswoss, I’ll find out the features.
– Eduardo