Having trouble displaying my arrays in HTML. I'm attempting to do this within a Chrome Extension. While I can view the array perfectly in console.log, I'm encountering issues when trying to add it to the HTML DOM:
/* Generating the array for the Chrome extension */
chrome.storage.local.get({wsitemad: []}, function (result) {
var wsitemadded = result.wsitemadded;
/* Gathering the required 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');
/* Adding the Data to the Arrays (Key/Value pairs) */
wsitemadded.push({WSItemNumber: witenumfetch, WSTitle: wspecialtitlefetch, WSImage: wspecialimg, WSPrice: wspecialprice, WSPrevPrice: wspecialprevprice, WSDELDate: wspecialdeldate});
chrome.storage.local.set({ wsitemadded: wsitemadded });
});
/* Showing the current stored Arrays */
setTimeout(
function(){
chrome.storage.local.get({wsitemadded: []}, function (result) {
var wsitemadded = result.wsitemadded;
console.log(wsitemadded); /* Shows the Arrays correctly in the Chrome Dev console */
$('#anydiv').text(wsitemadded); /* Should display all the Array data */
});
}, 300);
The code above is meant to display all the Array information in #anydiv
, right?
However, all I see is: [object Object],[object Object]
I've attempted using .toString()
but that didn't provide a solution.
Not sure if JSON.stringify
could assist and how I'd incorporate it if necessary?
I've been stuck on this dilemma for hours, done extensive research, and now I feel like I'm overlooking something obvious? Any assistance would be greatly appreciated. Please :-)