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

157
Vistas
Submit form one time after page load via Jquery

How to submit the cart request-quote form after page load? Below code is worked fine -

<?php if(!isset($_GET['updated'])) { ?>
<script>
jQuery(document).ready(function($) {
jQuery("#yith-ywraq-form").submit();
});
</script>
<?php } ?>

But avoid submitting forms, again and again, I reload to this action site.com/request-quote/?updated=data

But if someone refreshes the same page site.com/request-quote/?updated=data then I have no option to submit the form again on page load.

do you have a solution for this problem?

My requirement is I want to submit the cart request-quote form 1 time after page load?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You may use localStorage for this. Take a flag in set some initial value of it. When the form submits update it's value. By checking the same you can avoid getting submit.

<?php if(!isset($_GET['updated'])) { ?>
    <script>
        if(!localStorage.getItem('isFormAlreadySubmit')){
            jQuery(document).ready(function($) {
                jQuery("#yith-ywraq-form").submit();
                localStorage.setItem('isFormAlreadySubmit', true);
            });
        }
    </script>
<?php } ?>
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can move $_GET['updated'] to localStorage or sessionStorage, then you don't need to reload the page to ?updated=data page anymore.

  • localStorage will save updated value even when the browser is closed and reopened.
  • sessionStorage will save updated value but it will be cleared if the browser is closed.

That depends on you to choose which one. So I make a demo with sessionStorage which I prefer because when the user closes the browser, it will clear the updated value, maybe the next user in that device is another (public device). I also remove the check if(!isset($_GET['updated'])) condition.

<script>
  jQuery(document).ready(function($) {
    if (!sessionStorage.getItem('updated')) {
      jQuery("#yith-ywraq-form").submit();
      sessionStorage.setItem('updated', true);
    }
  });
</script>

Update: add live demo https://codepen.io/tuandaodev/pen/jOwvrRg?editors=1111

about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to use a server side session variable to check (duplicate) Answer

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