1
I have a problem related to HTML, Jquery and PHP, I will try to pass the most information. I have a PHP page that has to go back and forth with variables and it’s like a step by step, where each step sends its data to the next to filter the tables in the Mysql database. My problem is the variable goes but doesn’t come back. So I am including in the project AJAX requests, where when I click the button I send to the same page via POST in Jquery the values. The problem is that the variable is not taking this value. Could I set this variable after clicking on the button, or pass this value in another way? I will send the codes.
console.log($("#prox1"));
$("#prox1").click(function(event) {
console.log("Ok");
console.log($("#curso").val());
console.log($("#turno").val());
console.log($("input[name='tipoLab']:checked").val());
var dados1 = {curso: $("#curso").val(), turno: $("#turno").val(), tipoLab: $("input[name='tipoLab']:checked").val()};
$.post('../processamento/index.php', dados1, function() {
console.log("Fui e voltei");
});
});
<div class="ls-steps-content" id="step1">
<?php $sql ="SELECT cursos from cursos order by cursos asc";
$resultado = conecta( $maquina , $usuario, $senha, $banco, $sql );?>
<div class="ls-custom-select selectEtapa1">
<select id="curso" name="curso" class="ls-select">
<option selected="selected" disabled="disabled"> Cursos </option>
<?php while ($row = mysql_fetch_assoc($resultado)) {
$curso = $row["cursos"];
?>
<option value="<?=$curso?>"><?=$curso?></option>
<?php } ?>
</select>
</div>
<div class="ls-custom-select selectEtapa1">
<select id="turno" name="turno" class="ls-select">
<option selected="selected" disabled="disabled"> Turno </option>
<option value="Manha"> Manhã </option>
<option value="noite"> Noite </option>
</select>
</div>
<fieldset>
<!-- Exemplo com Radio button -->
<div class="ls-label col-md-5">
<p>Escolha uma das plataformas:</p>
<label class="ls-label-text">
<input type="radio" name="tipoLab" value="labinfo">
Laboratório de informática
</label>
<label class="ls-label-text">
<input type="radio" name="tipoLab" value="labEng">
Laboratorio de Engenharia
</label>
<label class="ls-label-text">
<input type="radio" name="tipoLab" value="labSau">
Laboratório de Saúde
</label>
</div>
</fieldset>
<div class="ls-actions-btn">
<form method="post" action="index.php">
<input type="hidden" name="curso">
<button type="submit" id="prox1" href="#" class="ls-btn-primary ls-float-right" data-action="next">Próximo</button>
</form>
</div>
</div>
<div class="ls-steps-content" id="step2">
<?php $_POST["curso"] ?>
<div class="ls-actions-btn">
<a href="#" class="ls-btn" data-action="prev">Anterior</a>
<a href="#" class="ls-btn-primary ls-float-right" data-action="next">Próximo</a>
</div>
</div>
If someone has another way to help me it can be too, I just need to keep going back and forth with these variables when the user wants.
Thanks in advance
I believe the error is when taking this data and not in sending
– Costamilam
which variable are you passing by? where it should return?
– yanntinoco
Should it return in this section <div class="ls-Steps-content" id="step2"> <?= $_POST["course"] ? > Since I sent her via POST to the same page in AJAX, in Inspector, I went to the Network and there are the parameters of the POST so I do not know why she is not receiving the same.
– Caio Alexandre