I’m using external library, jquery.cookies.2.2.0.min.js, and according to the documentation you get a list of all cookies like so.
jaaulde.utils.cookies.filter( /^site/ );
returns list of cookies whose names start with “site”
My code is as follows.
var all_cookies = $.cookies.filter( /^mark/ );
$('aside').html(''+all_cookies+'');
When I execute the above code though, the inner HTML of aside is [object Object]. What am I doing wrong?
This is because Jaaulde returns an object where the key is the name of the cookie and the value is the value of the cookie. So Jaaulde is returning something like this.
You can’t convert an object to a string like that. You need to iterate through each key-value pair and append those individually. Which can be done like so.