0
I’m trying to pass the data from one Form to another page: My Option is doing a query in Mysql to return the values within the option options.
<form method="POST" action="">
<div class="form-row">
<div class="form-group col-md-6">
<label>Nome da Impressora</label>
<?php
//include "config.php";
//clausula sql
$sql = "SELECT * FROM bd_print order by id";
//executa a clausula sql
$result = mysqli_query($con, $sql)or die("Falha na execução da instrução SQL!");
?>
<select name="nome_imp" class="form-control" id="tabela">
<option select> Selecione ...</option>
<?php
while($dados = mysqli_fetch_array($result))
{
echo "<option value='".$dados['nome']."'>".$dados['nome']."</option>";
}
echo "</select>";
?>
</select>
</div>
</div>
<button type="button" id="remover" class="botao btn btn-primary" />Remover</button>
</form>
Follow the code responsible for running the php script;
$(".botao").click(function(){
var vNome = $("#nome_imp").val();
$.ajax({
type: "POST",
data: {
nome_imp : vNome
},
url: "function/rmv_func.php",
dataType: "html",
success: function(result){
$("#respostabla").html('');
$("#respostabla").append(result);
},
beforeSend: function(){
$('#resposta').css({display:"block"});
},
complete: function(msg){
$('#resposta').css({display:"none"});
}
});
});
What happens is that the return of the post is "Undefined index "nome_imp", that is, the post is not being passed. If I do the action directly through FORM, it passes the POST. I believe my mistake is in the syntax of ajax, but I’m not able to identify where.
Correct, it was a primary mistake of mine not to notice it, but thank you for making time available and show me, thank you !!!
– Wilton Gallego