Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

103
Visualizações
When form submitting and the page refreshing my loading screen comes in agin?

I am trying to create a login page. I made a loading screen that fades when the page loads.

        $(window).on("load",function(){
            setTimeout(function() { 
                $(".loading").fadeOut("slow", function(){
                    $(".container").fadeIn("slow").css("display", "flex");
                });     
            }, 500);
        });

The problem is there when you submit a form and the page refreshes because then the loading screen comes in again. Any solution?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can prevent the form from submitting with

$("#prospects_form").submit(function(e) {
e.preventDefault();
})

Without jQuery:

var form = document.getElementById("myForm");
function handleForm(event) { event.preventDefault(); } 
form.addEventListener('submit', handleForm);
about 4 years ago · Juan Pablo Isaza Relatório

0

1- You can use Ajax for sending the form to the server.

2- Or do something like this:

// add an item to session before form submitting.
$(document).on('submit', function (e) {
    e.preventDefault()
    sessionStorage.setItem('notLoad', '1')
    $('form').submit() // add any attr to form idetifier.
})

$(window).on('load', function () {
    // check the session to know if the page loaded from form submitting or not:
    if (sessionStorage.getItem('notLoad') !== '1') {
        sessionStorage.removeItem('notLoad');
        setTimeout(function () {
            $('.loading').fadeOut('slow', function () {
                $('.container').fadeIn('slow').css('display', 'flex')
            })
        }, 500)
    }
})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda