0
I have the following code:
// JavaScript Document
$(document).ready(function(e) {
$("a.excluiAdmin").click(function() {
if (confirm('Deseja Excluir este Administrador?') ) {
var link = $(this);
$.ajax({
url: "../_requeridos/excluiAdministrador.php",
type: 'POST',
data : {
'administradorid' : $(this).attr('administradorid')
},
beforeSend: function() {
$(link).html("<img src='../_img/_bannerImgs/spinner.gif' />")
},
success: function (retorno) {
if (retorno == 1) {
alert('Excluido com sucesso');
location.reload();
} else {
alert("Erro na exclusão");
}
},
cache: false,
});
return false;
}
})
});
Within the confirm
i do:
var link = $(this);
Then I take the this
of object who suffers the action;
And in the beforeSend
doing:
beforeSend: function() {
$(link).html("<img src='../_img/_bannerImgs/spinner.gif' />")
},
So I can get the html
of the element a
who will receive the action.
I wonder if you could do something like
alert($(this).before($(this)).html())
And not depend on doing
var link = $(this);
it is possible that?
so the way I did it’s still more readable and less code!
– Carlos Rocha