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

144
Vistas
How to distinguish between POST and PUT inside a form submit listener

Consider a form with a single button of type "submit":

<button type="submit" id="formSubmitButton">Submit</button>

When loading the page, I send a GET-request to my server, which will return an object that is used to fill out the form. If there is no object inside my server-side database, the form will be empty. I have attached an EventListener to my form, such that when the form is submitted, a POST request is send to my server. I only want to send a post request, however, when the form was initially empty (on loading the page). If it wasn't, I want to send a PUT request instead. And I don't want to introduce another button inside my form. Else, I assume, I could just send the POST/PUT requests upon clicking on either buttton. I just want the single button though.

Does anyone know of a nice way to accomplish this?

about 4 years ago · Santiago Trujillo
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