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

280
Visualizações
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 Respostas
Responde à pergunta

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 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