I want $con
to be the selected value which is happening cause this echo '<p class="pop"></p>';
is working but I don't know how to put $con
inside my query so it can give me the selected value there.
This is the error in the php script
Notice: Undefined index: evento in C:\xampp\htdocs\simulator\modulo1\error.php on line 2 Notice: Undefined index: evento in C:\xampp\htdocs\simulator\modulo1\error.php on line 201 Conferencia
but how it is possible if is printing the value conferencia that is coming from error.php? I don't get it
index.php
<script>
$(document).ready(function () {
$('#tipologias').change(function () {
var con = $('#tipologias').val();
console.log(con);
$.ajax({
method: "post",
url: "error.php",
data: {evento:con}
})
.done(function(data){
$(".pop").html(data);
});
});
});
</script>
<?php
require_once 'error.php';
$con= $_POST['evento'];
echo $con;
echo '<p class="pop"></p>'; /* this work and print selected value without refreshing the page*/
$query = $mysqli->query("SELECT requerimientos FROM tipologia where tipologia=$con");
$rows = $query->fetch_array();
?>