I have the following jQuery code with an Ajax function
$(document).ready(function(){
$(".ver").click(function(event){
var pulsado = $(this).data("dnipass"); //pulsado is "12345678B" (a string) taken from php code
alert(pulsado);
event.preventDefault();
$.ajax({
type: 'POST',
url: 'adminVerLineas.php',
data: {
dni:$(this).data("dnipass"),
},
success:function(data){
alert(data); //Data is string(9) "123456789" , i can see the alert
$(this).closest('.form-group').next('.userInfo').append(data); //this doesnt append properly, but i want this to append
}
});
$(this).closest('.form-group').next('.userInfo').append(pulsado); //this appends properly
});
})
Problem is that the append inside de success functions isnt working, but the one outside does, i dont understand why is that happening
This is where im doing the append:
<div id ="<?= $i?>" class="table userInfo" data-formpost="<?= $dni?>"></div>
This is my adminVerLineas.php in case its needed:
<?php
var_dump($_POST["dni"]);
?>