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

348
Visualizações
How to redirect a user based on a returned HTML form response?

I have a HTML form that submits a POST request to a Nelify serverless function. The serverless function does some processing and then returns a URL.

I'm using a HTML form to call the Nelify serverless function because using a JavaScript fetch was throwing a CORS error. The HTML form does not.

The HTML of the form looks like this:

<html>
  <head>
  </head>
  <body>
    <form action="https://www.example.com/.netlify/functions/stripe-create-checkout-session" method="POST">
      <input type="hidden" name="priceId" value="price_1JZS_EXAMPLE" />
      <button id="stripe-btn" type="submit">Checkout Test Starter Plan</button>
    </form>
  </body>
</html>

Screenshot of the HTML form (just the button is visible):

enter image description here

When a response is received the page is changed in place, and the HTML of the form changes to look like this:

<html>
  <body>
    <pre>{"url":"https://checkout.stripe.com/pay/cs_test_a1XZXYz2N8iS46oPtgZUsCFqe434u1c76D5MQrGkNeIW0yjEHbs0oYAx3h#fidkdWxOYHwnPyd1blpxYHZxWjA0T18xUTxGNGFBQjNSZEhXcX0xQH9QcExWRGxwNVRoT39gfDA0f1d3UUM3f0ByQT12Z0IyfXBKbTVVb05jUnFnNlxqf3Y9bl9XMUJWPWlqanR3RD0wVVRUNTU0UH13TDBHRCcpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl"}
    </pre>
  </body>
</html>

And here is a screenshot of how that looks on the page:

enter image description here

With all that said, I have two questions:

  1. How do I grab the url in the reponse and redirect the user to that page? I know this requires JavaScipt but I'm not sure what that should be.
  2. I do not want the response to be rendered on the page. How do I stop it from showing to the user? Perhaps the redirect will hide this?
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you want to just grab the URL then follow the tutorial on w3schools here

https://www.w3schools.com/jsref/prop_doc_url.asp

and if you want to redirect after grabbing the URL then here is the tutorial.

https://www.w3schools.com/howto/howto_js_redirect_webpage.asp

and if we want url in response see this.

Get response of url in nodejs (express/http)

about 4 years ago · Juan Pablo Isaza Relatório
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