Linked Questions
16 questions linked to/from Store JSON object in data attribute in HTML jQuery
0 votes
2 answers
871 views
Can't parse JSON from data attribute [duplicate]
I'm currently trying to parse a JSON from a data attribute but I'm getting an error: Uncaught SyntaxError: Unexpected token � in JSON at position 0 This is my code: jQuery( document ).ready( ...
1 vote
4 answers
875 views
High level data structures in html data attribute [duplicate]
I am happy that the html5 data attribute exists. I can write a simple string into html attributes and access them via jquery. But .... wouldn't it be nice to have more than a simple string? Is ...
0 votes
2 answers
237 views
Replace many data-tags with one JSON string in html/jquery [duplicate]
I have a habit of using lots of data tags, and then reading them one at a time in jQuery e.g. *html* <span data-group="1" data-item="2" data-user="abc" data-type="...
587 votes
25 answers
301k views
Why is using the JavaScript eval function a bad idea? [closed]
The eval function is a powerful and easy way to dynamically generate code, so what are the caveats?
267 votes
17 answers
414k views
Using Javascript's atob to decode base64 doesn't properly decode utf-8 strings
I'm using the Javascript window.atob() function to decode a base64-encoded string (specifically the base64-encoded content from the GitHub API). Problem is I'm getting ASCII-encoded characters back (...
4 votes
2 answers
4k views
Store Object in data-attribute without jQuery
My question basically is exactly like this question. I am just wondering, if there is a way to achieve this without jQuery. The following code does not work. I have also tried it with an array, but ...
0 votes
1 answer
2k views
looping php array values to html data attribute
I have an array $myArray Array ( [0] => Array ( [Number] => 039 [Fruit] => Apple [Level] => Low [Names] => Array ( [6] =&...
1 vote
1 answer
2k views
Uncaught SyntaxError: Unexpected end of JSON input. Can't properly parse the info to JSON from the html
Getting the error when trying to open the modal with product details after products were queried with help of ajax Error itself: Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<...
0 votes
1 answer
1k views
jquery data attribute not parsing json string
I am saving array of javascript objects in the html data attribute using JSON.stringify(). When I try to retrieve the data using jquery .data() function, I do not get deserialized array of javascript ...
1 vote
2 answers
1k views
Get key value from a HTML attribute array javascript
This is the HTML attribute: data-plugin-options="{'Enabled': true, 'StartAt': 30, 'EndAt': 65}" How can get the value of the keys by javascript by the key name? Such as 'StartAt' value.
1 vote
2 answers
695 views
Send data from Phoenix to Javascript in Slim template
I have figured out a way to do this, defining a variable inside a HTML attribute like this: div data-name=some_var id="component" Then from Javascript I can retrieve it: alert($("#component").data("...
0 votes
2 answers
1k views
Pass a JSON array into dynamically created onclick method of button jQuery
Following is my code and data is json array i want to pass in onclick method of Update button function populateData(data) { $(".studentPanel").show(); for (var i = 0; i < data....
1 vote
2 answers
73 views
scoping html data with js or jquery
This is my html ( in twig template ) <li id="{{folder.id}}" data-jstree='{"icon":"glyphicon glyphicon-tags", "type":"folder"}' ><a href="#">{{folder.name}}</a> I am trying to get ...
0 votes
1 answer
306 views
Get a value from data-actions attribute
This is a revolution slider button. I would like to get the "rs-26" from the data-actions attribute of a div. How can I get it using jQuery? data-actions="[{"event":"click","action":"jumptoslide","...
0 votes
2 answers
187 views
JS: Passed JSON-Array loses quotation marks
Basically I'm trying to pass an json-array via onclick to a function <button onclick='showAccountOverviewModal("<%= accounts[j].name %>", `<%= accounts[j].bills%>`)'> Click Me &...