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

101
Vistas
JAVASCRIPT Get youtube json search

I'm having a little difficulty in my code and I would like a light, I will leave my code below for you to understand, I want that when I click on " #btn_search_youtube " it returns the JSON with the results of my search, example ("http://127.0.0.1/youtube/search?q= {SEARCHCONTENT}").

I found a website that does something similar, I'll leave it below for better understanding "https://server1.mtabrasil.com.br/youtube/search?q=akon"

my code:

$("#btn_search_youtube").click(function() {
    let search_youtube = $("#search_youtube").val();
    $("#result_youtube tbody").empty();
    $("#result_youtube").hide();
    $("#loading_youtube").show();

    $.getJSON("http://127.0.0.1/youtube/search?q="+search_youtube, function(resultado) {        
        $.each(resultado.items, async function(i, item) {
            if (item.type == "video") {
                let link = "http://127.0.0.1/youtube/play?id="+item.id;
                let link_download = "http://127.0.0.1/youtube/download?id="+item.id;
                $("#result_youtube tbody").append(`
                    <tr>
                        <td><img src="https://img.youtube.com/vi/${item.id}/default.jpg" alt="" style="width: 67px;height: 67px;"></td>
                        <td style="width: 60%;">
                            <strong>${item.title}</strong><br><audio controls="" preload="none">
                                <source src="${link}" type="audio/mpeg">
                            </audio>
                        </td>
                        <td>
                            <span class="glyphicon glyphicon-time"></span> ${item.duration}
                        </td>
                        <td>
                            <a href="${link_download}" class="btn btn-default"><i class="glyphicon glyphicon-cloud-download"></i> Download</a>
                            <button onclick="copy('setradio ${link}')" type="button" class="btn btn-default"><span class="glyphicon glyphicon-link"></span> Copiar URL</button>
                        </td>
                    </tr>
                `);
            }
        });

        $("#result_youtube").show();
        $("#loading_youtube").hide();
    });
    
});
about 4 years ago · Juan Pablo Isaza
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