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

159
Views
¿Cómo enviar una solicitud de obtención cuando se hace clic en el encabezado de la tabla de una página html?

Esta es la tabla html y tiene muchos encabezados de tabla como s.no., nombre, etc. Entonces, cada vez que se hace clic en cualquier encabezado, quiero enviar una solicitud de obtención con algunos valores diferentes para cada encabezado.

El siguiente es el código de tabla que he usado.

 <table class = "table" style = "margin-left:auto;margin-right:auto"> <thead> <tr> <th id = "s.no.">S.No.</th> <th id = "fname">First Name</th> <th id = "lname">Last Name</th> <th id = "email">Email</th> <th id = "password">Password</th> <th id = "dob">Date of Birth</th> <th id = "gender">Gender</th> <th id = "hobbies">Hobbies</th> </tr> </thead> <tbody> {% for candidate in candidates%} <tr> <td>{{candidate.id}}</td> <td>{{candidate.fname}}</td> <td>{{candidate.lname}}</td> <td>{{candidate.email}}</td> <td>{{candidate.password}}</td> <td>{{candidate.dob}}</td> <td>{{candidate.gender}}</td> <td>{{candidate.hobbies}}</td> </tr> {% endfor %} </tbody> </table>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Espero que este código te ayude.

 let tableHead = document.getElementsByTagName("thead")[0]; tableHead.addEventListener("click", function(){ httpRequest = (url, method = 'GET') => { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.open(method, url); xhr.onload = () => { if (xhr.status === 200) { resolve(xhr.responseText); } else { reject(new Error(xhr.responseText)); } }; xhr.send(); });} });
 <table class = "table" style = "margin-left:auto;margin-right:auto"> <thead> <tr> <th id = "s.no.">S.No.</th> <th id = "fname">First Name</th> <th id = "lname">Last Name</th> <th id = "email">Email</th> <th id = "password">Password</th> <th id = "dob">Date of Birth</th> <th id = "gender">Gender</th> <th id = "hobbies">Hobbies</th> </tr> </thead> <tbody> <tr> <td>test</td> <td>test</td> <td>test</td> <td>test</td> <td>test</td> <td>test</td> <td>test</td> <td>test</td> </tr> </tbody> </table>

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!