$(function() { $(".form-signin").on("submit", function(event) { event.preventDefault(); $.ajax({ type: $(this).attr('method'), url: $(this).attr('action'), data: $(this).serialize(), dataType: "json", success: function(response) { if (response.httpCode === 200) { window.location.href = response.redirect || "/site"; return; } handleLoginResponse(response); }, error: function(jqXhr, textStatus, errorMessage) { console.log("Error: " + errorMessage); if (jqXhr.status === 503) { popZ("Estamos aplicando uma atualização, tente novamente mais tarde."); return; } handleLoginResponse(jqXhr.responseJSON || {}); } }); }); }); function handleLoginResponse(response) { if (response.result === "activation_pending" || response.httpCode === 403) { popZ("Seu cadastro está pendente. O e-mail de ativação já foi enviado."); return; } popZ("E-mail ou senha incorretos"); }