Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!