0
I got the following jQuery
script:
$.ajax({
url: "_scripts/_php/_validacoes/cadastrarCelulaMembro.php",
type: "POST",
dataType: "json",
data: {
idPastor : $("#idPastor").val(),
idRede : $("#idRede").val(),
idRegiao : $("#idRegiao").val(),
idArea : $("#idArea").val(),
idSetor : $("#idSetor").val(),
idCelula : $("#idCelula").val(),
idMembro : $("#idMembro").val()
},
beforeSend: function() {
$("#buttonCadastrarCelulaMembro").attr('display','none');
$("#imgCarregando").attr('display','block');
},
success: function (result) {
$("#buttonCadastrarCelulaMembro").attr('display','block');
$("#imgCarregando").attr('display','none');
if (result[0] == "Erro")
$(".resposta").html(result[1]);
else
$(".resposta").html(result[1]);
}
});
}
The idea is to enter the $.ajax
and before sending the form, give a display: none
in the button and a display: block
in a image of Loader
beforeSend: function() {
$("#buttonCadastrarCelulaMembro").attr('display','none');
$("#imgCarregando").attr('display','block');
},
And, after receiving the return of PHP, do the reverse process.
success: function (result) {
$("#buttonCadastrarCelulaMembro").attr('display','block');
$("#imgCarregando").attr('display','none');
...
But this is not happening.
Where am I going wrong?
This is the end of the form:
...
<button id="buttonCadastrarCelulaMembro" class="button">Cadastrar Membro na Célula</button>
<img id="imgCarregando" style="display: none" src="_imgs/carregando.gif" />
<br />
<div class="resposta"></div>
</div>
<div class="dadosMembro"></div>
Buuton class CSS
.button {
width: 250px;
height: 30px;
margin: 3px;
}
I forgot that css is not attribute but style. In this case, it has to be . css() , not . actribute() or . prop().
– Carlos Rocha