Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

313
Vistas
Several ways of preventing a form to submit the normal way?

I have a little php experience and would like to learn ajax jQuery. I've been watching several tutorials on submitting a form without refreshing the page. I notice people use different ways to prevent a form from submitting the normal way (with a page refresh):

  • with the event.preventDefault() function
  • using return false
  • In a script I'm trying to understand the JS script starts with:

    $("#submitBrandForm").unbind('submit').bind('submit', function() {

Does this also have the same functionality? This same script ends with 'return false', which confuses me (and makes me think the unbind - bind code has another purpose).

Thanks

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

No, the third one doesn't do the same thing. unbind only removes any previously attached event handlers (via bind), it does not prevent the form from being submitted.

In your example unbind and bind are just used to replace the existing event handler(s). If you don't unbind first, bind will add a handler to the ones that are already attached. You'll also often see unbind('submit', ...) inside the handler for a submit event that programmatically submits the form, to prevent the function from calling itself endlessly, like in this answer.

By the way, bind and unbind have been deprecated, you should be using on and off.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda