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

267
Views
¿Cómo cambiar la página y la función de llamada al mismo tiempo?

¡AYUDA! El evento onClick necesita enviar datos al servidor y cambiar la página al mismo tiempo. Aquí está mi código, pero los datos se envían con el método POST, pero la página no cambia...

 const commandButton = document.getElementById("order"); commandButton.onclick = function () { createOrder(); // A function that sends users data to server with POST method window.location.href = "http://127.0.0.1:5500/front/html/confirmation.html"; };
 function createOrder() { const firstName = document.getElementById("firstName").value; const lastName = document.getElementById("lastName").value; const address = document.getElementById("address").value; const city = document.getElementById("city").value; const email = document.getElementById("email").value; const newCustomer = { // newCustomer is an object which will be changed into string with JSON.stringify contact: { firstName: firstName, lastName: lastName, address: address, city: city, email: email, }, products: panier, };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que el problema se debe a que no ha impedido que el formulario haga su propia solicitud general, intente usar event.preventDefault(); en el controlador onclick para evitar que el formulario realice su operación general y verifique que resuelva el problema o no.

 const commandButton = document.getElementById("order"); commandButton.onclick = function (event) { event.preventDefault(); createOrder(); // A function that sends users data to server with POST method window.location.href = "http://127.0.0.1:5500/front/html/confirmation.html"; };
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!