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

147
Visualizações
jquery How to get 2 json into 1 table

im trying to make this table:

<table id="list">
            <th>ID</th>
            <th>Name</th>
            <th>Price</th>
            <th>Image</th>
        </table>

and i have this javascript: in this JS... i get all producs and add it like: ID NAME PRICE IMAGE 1320 Keyboard 10.3 ??? 1221 Mouse 10.4 ???

the image is obtained from other api with a 1320 the ID of the Product..... (https://example.com/image/product/1320) it give 1 image in text in base64

i can return the image and the data... but i need add the image into the same table what i fill with name and price...

how can make it?

This my JS

<script>
        $(document).ready( function () {
            $.ajax({
                url: "https://example.com/products", 
                type: "GET",          
                cache: true,
                dataType: "json",

                success: function(response){

                    $.each(response.resultProducts, function (key, value) { 
                        $('#list').append("<tr>\
                            <td>"+value.id+"</td>\
                            <td>"+value.productName+"</td>\
                            <td>"+Math.round(value.Price/12).toFixed(2)+"</td>\
                            </tr>");

                    });

                    

                }

            });

        });



        $.ajax({
                    url: "https://example.com/image/product/"+value.id+"", 
                    type: "GET",          
                    cache: true,
                    dataType: "text",

                    success: function(response){

                         var table = $("#list");

                         var xx = '<img src="data:image/png;base64, '+response+'" />';

                            table.append("<tr>\
        <td>"+xx+"</td>\
        </tr>");
                    }

                  });


    </script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to setup placeholders for the images and then use ajax to fill in the images later. Something like:

    $(document).ready( function () {
      $.ajax({
        url: "https://example.com/products",
        type: "GET",
        cache: true,
        dataType: "json",
        success: function(response){
          $.each(response.resultProducts, function (key, value) {
            $('#list').append("<tr>\
                                <td>"+value.id+"</td>\
                                <td>"+value.productName+"</td>\
                                <td>"+Math.round(value.Price/12).toFixed(2)+"</td>\
                                <td class="+value.id+"></td>>\
                                </tr>");
            $.ajax({
              url: "https://example.com/image/product/"+value.id+"",
              type: "GET",
              cache: true,
              dataType: "text",
              success: function(response){
                $("#list td."+value.id).replaceWith('<td><img src="data:image/png;base64, '+response+'" /></td>');
              }
            });
          });
        }
      });
    });
about 4 years ago · Juan Pablo Isaza Relatório
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