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

171
Views
javascript XMLHttpRequest necesita controlador?

Arranque de primavera 2.6.2
Java 11
hoja de tomillo

directorio

Mi objetivo es cargar navbar.html a través de javascript cuando se abre categoryTest.html.
En primer lugar, agrego este código a categoryTest.html

 <nav class="navbar" includeHTML="navbar.html"> </nav>

Y ahí está la función que escribí.

 function includeHTML() { var z, i, elmnt, file, xhttp; z = document.getElementsByTagName("*"); for (i = 0; i < z.length; i++) { elmnt = z[i]; file = elmnt.getAttribute("includeHTML"); if (file) { xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4) { if (this.status == 200) {elmnt.innerHTML = this.responseText;} if (this.status == 404) {elmnt.innerHTML = "Page not found.";} } } xhttp.open("GET", file, true); xhttp.send(); return; } } }

Cada vez que inicio el servidor y veo el resultado, xhttp.send() es el problema.

Pero una vez que agrego este método a mi controlador, funciona bien.

 @GetMapping("/navbar.html") public ModelAndView navbar(){ ModelAndView modelAndView = new ModelAndView("navbar"); return modelAndView; }

No sé por qué se requiere este método para este proceso.

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!