Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!