I'm having a little problem that starts with sending the form to the same page and displaying the parameters in a modal, but I can not get them through the post, follow the code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="Meulocalhost/css/style.css">
<script src="Arquivos/ArquivosUteisParaSites/BibliotecaJS/jquery-3.3.1.min.js"></script>
<script>
$(document).ready(function() {
var modaladm = document.getElementById('modal-adm');
var btn = document.getElementById("myBtn-adm");
var span = document.getElementsByClassName("close-adm")[0];
span.onclick = function() {
modaladm.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modaladm) {
modaladm.style.display = "none";
}
}
$('#ajax_form').submit(function(e) {
e.preventDefault();
var id = $(this).serialize();
$.ajax({
type: 'POST',
url: 'teste2.php',
data: id,
success: function(returnhtml) {
alert(id);
modaladm.style.display = "block";
}
});
return false;
});
});
</script>
</head>
<body>
<div class="table">
<div class="tbl-header">
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>checkbox</th>
<th>id</th>
<th>nome</th>
<th>login</th>
<th>senha</th>
<th>email</th>
<th>imagen</th>
</tr>
</thead>
</table>
</div>
<div class="tbl-content">
<table cellpadding="0" cellspacing="0" border="0">
<form action="recebe.php" method="post" id="ajax_form">
<tbody>
<?php
require_once("Meulocalhost\db\conecta.php");
$query_usu = "SELECT * FROM usuarios";
$sql_usu = mysqli_query($_conexao,$query_usu) or die (mysqli_error());
$rows = mysqli_num_rows($sql_usu);
while($_line = mysqli_fetch_array($sql_usu)){
if($_line['imagen'] == null){
$_line['imagen'] = "sem imagen";
}
?>
<tr>
<td>
<input type="radio" name="id_usu" id="id_usu" value="<?php echo $_line['id'];?>">
</td>
<td>
<?php echo $_line['id'] ?>
</td>
<td>
<?php echo $_line['nome_comp'] ?>
</td>
<td>
<?php echo $_line['login'] ?>
</td>
<td>
<?php echo $_line['senha'] ?>
</td>
<td>
<?php echo $_line['email'] ?>
</td>
<td>
<?php echo $_line['imagen'] ?>
</td>
</tr>
<?php
}
?>
</tbody>
<button type="submit">alterar</button>
</form>
</table>
</div>
</div>
<span id="result"></span>
<div id="modal-adm" class="modal">
<?php
$id = $_POST['id'];
?>
<div class="modal-content">
<div class="modal-header">
<span class="close-adm">×</span>
<h2>Modal</h2>
</div>
<div class="modal-body">
<input type="text" value="<?php echo $id ?>" disabled>
</div>
<div class="modal-footer">
<h3>Modal Footer</h3>
</div>
</div>
</div>
</body>
</html>