Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

102
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda