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

401
Views
Genere una tabla html desde json url con datos de clave, valor también de padre sin clave

Estoy generando una tabla html con datos de json url. Quiero incluir el valor principal sin clave para estos datos.

Estructura json:

 { "gzpik1gqlnm": {"owner_name":"user02","room_name":"131","country":"EN","max":2,"current":1,"password":0}, "d1vn67n7sgu": {"owner_name":"user09","room_name":"254","country":"EN","max":2,"current":1,"password":0} }

JavaScript:

 setInterval(function(){ $.getJSON("somejson.url", function(data){ var room_data = ''; $("#roomtabletbody").empty(); $.each(data, function(key, value){ room_data += '<tr valign="top">'; room_data += '<td>'+value.country+'</td>'; room_data += '<td>'+value.owner_name+'</td>'; room_data += '<td>'+value.room_name+'</td>'; room_data += '<td>'+value.current+'/'+value.max+'</td>'; room_data += '<td>'+value.password+'</td>'; room_data += '<td><a class="join" href="">Join</a></td>'; room_data += '<tr>'; }); $('#roomtabletbody').append(room_data); }); }, 1000);

tabla generada:

 country owner_name room_name current/max password EN user02 131 1/2 0 EN user09 254 1/2 0

mesa a la que estoy tratando de llegar:

 parent country owner_name room_name current/max password gzpik1gqlnm EN user02 131 1/2 0 d1vn67n7sgu EN user09 254 1/2 0

¿Cuál es la dirección correcta?

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

0

Antes room_data += '<td>'+value.country+'</td>'; , agregue: room_data += '<td>'+key+'</td>';

Y éxito. Si cree que esta es la respuesta correcta, no olvide marcarla como respuesta correcta.

 setInterval(function(){ $.getJSON("somejson.url", function(data){ var room_data = ''; $("#roomtabletbody").empty(); $.each(data, function(key, value){ room_data += '<tr valign="top">'; room_data += '<td>'+key+'</td>'; room_data += '<td>'+value.country+'</td>'; room_data += '<td>'+value.owner_name+'</td>'; room_data += '<td>'+value.room_name+'</td>'; room_data += '<td>'+value.current+'/'+value.max+'</td>'; room_data += '<td>'+value.password+'</td>'; room_data += '<td><a class="join" href="">Join</a></td>'; room_data += '<tr>'; }); $('#roomtabletbody').append(room_data); }); }, 1000);

No olvide agregar un nuevo encabezado en <thead> .

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!