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

449
Views
Los archivos JavaScript y CSS no funcionarán en html (aplicación de arranque de primavera)

Tengo un problema con un archivo html que no 'carga' los archivos js y css correctamente. Este es mi código html:

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Create new snippet</title> <script src="static/js/send.js"></script> <link rel="stylesheet" href="static/css/button.css"> </head> <body> <textarea id="code_snippet" placeholder="//write your code here"></textarea><br/> <button type="submit" onclick="send()">Submit</button> </body> </html>

Se supone que debe tomar alguna entrada en la etiqueta de área de texto y enviarla a una base de datos cuando hace clic en el botón. Sin embargo, la función enviar() no funciona en absoluto. Además, el CSS vinculado no funciona tan bien. Esta es la estructura de mi proyecto:

ingrese la descripción de la imagen aquí

Esta es la función enviar():

 function send() { let object = { "code": document.getElementById("code_snippet").value }; let json = JSON.stringify(object); let xhr = new XMLHttpRequest(); xhr.open("POST", '/api/code/new', false) xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8'); xhr.send(json); if (xhr.status != 200) { alert("Something went wrong!"); } else if (xhr.status == 200){ alert("Success!"); } }

Esta función funciona bien cuando la pongo dentro de la etiqueta del script

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe asegurarse de que los enlaces sean relativos o absolutos al directorio de inicio.

/ruta absoluta y uso sin "/" para la ruta relativa

intente acceder a los enlaces de archivos css y js desde el navegador.

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!