Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

98
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda