I have this code:
$('.solicitud_amistad').click(function(){
var aux = $(this);
console.log($(this));
console.log($(this).data('receptor'));
$.post('amistad/nueva' , {id_receptor:$(this).data('receptor')},
function(response){
aux.replaceWith(response)
}
);
});
and I’m getting this output:
<a class="solicitud_amistad" data-receptor="4">Enviar solicitud de amistad</a>
undefined
I expected a 4 instead of undefined.
Try:
If that doesn’t work then you are failing to set the data correctly and will need you to post where you store data against the key called receptor.