1
I have a link a
, that if clicked, leads to a scrpt ajax for the deletion of ID.
With the código
below I can’t catch the id
in page of php
// JavaScript Document
$(document).ready(function(e) {
$("a.bloqDesbloq").click(function() {
$.ajax({
url: "../_requeridos/bloqueiaAdministrador.php",
type: 'POST',
data : {
'idadministrador' : $(this).attr('idadmin'),
'bloq' : $(this).attr('bloq')
},
beforeSend: function() {
},
success: function (retorno) {
if (retorno == "OK") {
alert('Bloqueado com sucesso');
location.reload();
} else {
alert("Erro na bloqueio");
}
},
cache: false,
contentType: false,
processData: false
});
return false;
});
});
the $_post
arrives in the php empty array.
Where am I going wrong?
Note: If I do
alert( $(this).attr('idadmin'))
Before calling the ajax
, the values appear
The data that will be sent to PHP should be in
data
. Try to do something likedata: {idadministrador: ...}
– Woss
I did this, but it is undefined in php. post e get in php with Array ( ) Array ( ). That is, empty arrays
– Carlos Rocha
how is the code before calling ajax? maybe your "$(this)" no longer represents the field you want to pull the information.
– Henrique Pauli
before ajax has nothing. But as stated in the question, if I give an Alert in $(this). attr('idadmin') before ajax, the value is normal
– Carlos Rocha
added the whole question js to make it clearer
– Carlos Rocha
Place the contents of your
a.bloqDesbloq
, I want to understand why you’re picking up an attributeidadmin
and anotherbloq
of the sametag <a>
– Dobrychtop