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

146
Views
Jquery demasiadas solicitudes ajax disparadas

¿Por qué este código envía exactamente dos solicitudes para cada cambio de control deslizante?

Tengo una aplicación de servidor en python del matraz, y estoy usando ajax de JQuery para enviar una solicitud a mi punto final, que devuelve un nuevo código de trama html. El servidor Flask siempre recibe dos solicitudes por cambio de control deslizante. ¿Cómo puedo arreglarlo, que enviaría una solicitud?

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="../static/style.css" rel="stylesheet" type="text/css"> <title>plot</title> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script type='text/javascript'> $(function () { var form = $('form'); $('#myRange').on('change mouseup', function () { $.ajax({ type: "POST", url: "/update_view", data: form.serialize(), }).done(function (res) { $("#plot").html(res) }); }); }); </script> </head> <body> <div id="body_page"> <form> <p>Default range slider:</p> <input type="range" min="1" max="100" value="50" id="myRange" name="slider"> </form> <div id="plot"> {{ html_plot|safe }} </div> </div> </body> </html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

porque estás subscribed a dos eventos change mouseup .

 $(function () { var form = $('form'); $('#myRange').on('change mouseup', function (e) { console.log(e.type); // return TWO events /* $.ajax({ type: "POST", url: "/update_view", data: form.serialize(), }).done(function (res) { $("#plot").html(res) }); */ }); });
 <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <form> <p>Default range slider:</p> <input type="range" min="1" max="100" value="50" id="myRange" name="slider"> </form>

En este caso, solo puedes dejar change

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!