1
Well, I don’t know if my title refers to what I’m asking, but I have a form with a Sign in button.
<button id="btn_entrar" data-loading-text="carregando..." autocomplete="off" class="btn btn-primary btn-cons m-t-10" type="submit" onclick="return Get_Acesso();">Entrar</button>
And when I enter login and password I want this button to be "loading..." then I looked it up on the Internet and I saw this case:
$('button[data-loading-text]').on('click', function () {
var btn = $(this)
btn.button('loading')
setInterval(function () {
btn.button('reset')
}, 3000)
});
But I don’t want a set time ( in case 3 seconds ) I want it to reset after my function GetAcesso() give some return be it false or true. Someone knows a solution?
function Get_Acesso(){
usuario = document.getElementById('txt_user_name').value;
senha = document.getElementById('txt_password').value;
LoginDTO.Usuario = usuario;
LoginDTO.Senha = senha;
var DTO = { 'LoginDTO': LoginDTO};
//acessar login
$.ajax({
type: "POST",
url: "default.aspx/Acesso_Login",
data: JSON.stringify(DTO),
contentType: "application/json; charset=utf-8",
dataType: "json",
beforeSend: function () {
$('#btn_entrar').html('Carregando...');
},
success: function (msg) {
$('#btn_entrar').html('Entrar');
try {
//tratamentos de msg
if (msg.d == "err") {
document.getElementById('spn_retorno').innerHTML = "Erro inesperado no momento do acesso.";
return false;
//Não encontrou nenhum registro
} else if (msg.d == "not") {
document.getElementById('spn_retorno').innerHTML = "Usuário / senha inválido.";
return false;
//Campos vazios
}
Simple access code, but I want that when the error return it comes back with the default button of "Enter".
Gabriel, put your reference code where you use the function
GetAcesso– KaduAmaral
When you press to enter gives some error in Chrome Inspect Element of script ? See there.
– Diego Souza
No error appears
– Voltz
Ahh, delete that function.
$('button[data-loading-text]')...– Diego Souza
worked, actually it was on the button itself I took it out of html and it worked "data-loading-text="loading..."". Thanks!
– Voltz
All right, that was also for taking away. Good!
– Diego Souza