Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda