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

384
Views
jquery: cómo cambiar el texto en el botón cuando se hace clic y cuando se hace clic

tengo este botón que envía un formulario a través de ajax (sin cambio de página)

 <button name="btn_invio" id="btn_invio-<?=$id_hotel?>" type="submit" class="btn btn-success btn-sm shadow-none" style="margin-top:5px; margin-left:5px; margin-right:5px; width:100%;">Send</button>

Ahora cambio el texto cuando el usuario hace clic en el botón para que el botón cambie de "enviar" a "enviando..."

 $("#btn_invio-<?=$id_hotel?>").click(function(){ $('#btn_invio-<?=$id_hotel?>').html('Sending...'); });

esto esta funcionando

Ahora quiero volver a mostrar la palabra "enviar" (para enviar otro mensaje) después de enviar el formulario

¿Cómo puedo hacerlo? Gracias

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe usar un evento de envío para su formulario. Entonces $.ajax . Algo como:

 $("#yourForm").submit(function(e) { e.preventDefault(); // avoid to execute the actual submit of the form. var form = $(this); var actionUrl = form.attr('action'); $('#btn_invio-<?=$id_hotel?>').html('Sending...'); $.ajax({ type: "POST", url: actionUrl, data: form.serialize(), // serializes the form's elements. success: function(data) { $('#btn_invio-<?=$id_hotel?>').html('Send'); } }); });
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!