The console shows me that the variable has not been defined 'undefined' my js
function UpdateUser(str){
var id = str;
var name = $('#nm-'+str).val();
$.ajax({
type: "POST",
url: "app/bin/adduser.php?p=update",
data: "id="+id+"&nm="+name,
success: function(data){
console.log(data);
console.log(name);
console.log(id);
viewUser();
}
})}
the input to send the data
<div class="modal-body">
<input type="hidden" id="<?php echo $user->id; ?>" >
<div class="form-group">
<label for="nm">Nombre</label>
<input type="text" class="form-ivss" id="nm-<?php echo $user->name; ?>" value="<?php echo $user->name; ?>">
</div>
Where I get the data
elseif ($page == 'update'){
$id = $_POST['id'];
$name = $_POST['nm'];
echo $name;
echo $id;
P.D: it is worth noting that I receive the id but not the name