Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
How to make the text/id I give can be brought from the URL I am requesting

I need to write an ID (from 1 to 10) and to be displayed on a table but I don't know how to bring the ID I wrote to the print, how do I display ONLY the data from certain ID of the json file?

<label for="ide">ID:</label>
<input id="ide" type="search" placeholder="ID" name="ide">
<button id="boton" type="submit">Buscar</button>
<table class="table bordered">
    <thead>
        <tr>
            <th>UserID</th>
            <th>ID</th>
            <th>Title</th>
            <th>Completed</th>
        </tr>
    </thead>
    <tbody id="tabla">
    </tbody>
</table>
function ajax() {
    const url = "https://jsonplaceholder.typicode.com/users";

    axios.get(url)
        .then((res) => {
            show(res.data)
        })
        .catch((err) => {
            console.log(data);
        })
}

function show(data) {
    for (const id of data) {
        tabla.innerHTML += `
            <tr>
                <td>${id.id}</td>
                <td>${id.name}</td>
                <td>${id.username}</td>
                <td>${id.email}</td>
            </tr>
        `
    }
}

document.getElementById("boton").addEventListener("click", function() {
    ajax();
});
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Declare a variable for id first

let id = 0

document.getElementById("ide").addEventListener("onchange", function(e) {
    id = e.target.value
});

Your ajax function should be like this:

 function ajax() {
        const url = `https://jsonplaceholder.typicode.com/users/:${id}`;
    
        axios.get(url)
            .then((res) => {
                show(res.data)
            })
            .catch((err) => {
                console.log(data);
            })
    }
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda