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

134
Views
La ruta no funciona en Vanilla Javascript SPA

Estoy trabajando en una aplicación de una sola página, ahora atascado en el enrutamiento, he intentado diferentes formas pero mi código siempre devuelve 404. Necesito ayuda ahora

 const route = (event) => { event = event || window.event; event.preventDefault(); window.history.pushState({}, "", event.target.href); handleLocation(); }; const routes = { 404: 404. php ', // http://localhost/spa/404.php', 'index': 'index.php', 'preparing': 'preparing.php', 'completed': 'completed.php', }; console.log("routes ", routes); const handleLocation = async() => { const path = window.location.href; const route = routes[path] || routes[404]; console.log("routes", route); const html = await fetch(route).then((data) => data.text()); document.getElementById("main-nav").innerHTML = html; }; window.onpopstate = handleLocation; window.route = route; handleLocation();
about 4 years ago · Juan Pablo Isaza
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!