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

204
Visualizações
Chrome Extension Get/Set Arrays display in console but not in html dom

I'm having display my arrays in html. I'm trying to achieve this in my Chrome Extension. I can see the Array perfectly in console.log, however not when trying to add it to the html dom:

    /* Creates the array for chrome extension */
    chrome.storage.local.get({wsitemadded: []}, function (result) {
      var wsitemadded = result.wsitemadded;
    /* Collects the desired data */
      var witenumfetch = $('#wsitemnumber').text();
      var wspecialtitlefetch = $('#title').val();
      var wspecialprice = $('.mwsb-wsp').text();
      var wspecialprevprice = $('.mwsb-prevprice').text();
      var wspecialdeldate = $('.mwsb-deldate').text();
      var wspecialimg = $('#postad-img-0 div img').attr('src'); 
      /* Pushes the Data into the Arrays (Key/Value) */
      wsitemadded.push({WSItemNumber: witenumfetch, WSTitle: wspecialtitlefetch, WSImage: wspecialimg, WSPrice: wspecialprice, WSPrevPrice: wspecialprevprice, WSDELDate: wspecialdeldate});
      
      chrome.storage.local.set({ wsitemadded: wsitemadded });
    });
   /* Displays current stored Arrays */
    setTimeout(
      function(){
      chrome.storage.local.get({wsitemadded: []}, function (result) {
        var wsitemadded = result.wsitemadded;
        console.log(wsitemadded); /* Displays the Arrays correctly in Chrome Dev console */
        $('#anydiv').text(wsitemadded); /* Should display all the Array data */
      });
     }, 300);

The above code should show all the Array information in the #anydiv correct?

However, the only information I get is: [object Object],[object Object]

I've also tried .toString() which didn't help.

I'm not sure if JSON.stringify could help me and how I would implement it if it does?

I've been stumped on this for hours, so much research and now I feel like my brain is scrambled and I'm missing something obvious? Any help would be hugely welcome. Please :-)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Have you already tried the following?

$('#anydiv').text(JSON.stringify(wsitemadded));

If it does not work well, you should show what you saw in console for console.log(wsitemadded).

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