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

281
Vistas
How to call async function inside a onClick (Button Click)

I am new to javascript and I am trying to create the following:

I have a search form for flights and after a user clicks Search, the user immediately gets the results.

I want to change this process. When a user fills the search form and clicks Search I want a POPUP screen to show with the Terms and conditions with a button "I understand". The results of the search will be shown only if the user clicks the button "I understand" in the POPUP.

I am trying to use await and async but I have no success still..

Here is the main code:

export function initSearchButtonOnClick() {
  $("#search-button").on("click", function (e) {
    activateLoadingOverlay2() // POPUP window Tearms & Condition


    // the code down needs to happen only after the user click the button "I understand" in the POPUP window.
    console.log("blerdii");

    e.preventDefault();
    switch (flightType) {
      case "rt":
      case "ow":
        if (
          $("#from-destination")[0].reportValidity() &&
          $("#to-destination")[0].reportValidity()
        ) {
          const fromDestination = $("#from-destination")
            .val() 
    More code below
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

javascript is asynchrone and mono-thread. Forget about await and async.

From your popup HTML template, you have to bind a function when the user click on the button "I understand". That all.

Your function activateLoadingOverlay2() should register an event listener of the "I understand" button to do what you want.

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