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

175
Views
¿Cómo alertar al usuario antes de salir de la página web y ejecutar la función ajax si el usuario presiona "ok"?

Tengo esta función que se supone que debe preguntar al usuario si está seguro de que quiere abandonar o actualizar el sitio web y si dice que sí y se va, se ejecuta la función ajax. Mi problema es que si la función ajax está sola, el usuario no recibe ninguna advertencia, pero si hay algo más en el código, la función ajax no funciona.

 <script type="text/javascript"> window.onbeforeunload = function () { return ""; $.ajax({url: "checkout.php", type : 'post', data : { page_left: 1}}); } </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

 <script type="text/javascript"> window.onbeforeunload = function () { if (window.confirm("Do you really want to leave?")) { $.ajax({url: "checkout.php", type : 'post', data : { page_left: 1}}); } } </script>

Mira esto te ayudará

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!