Hey there, currently I am working on sending an encoded JSON through the onclick
attribute. However, I am facing a challenge because the JSON contains strings with a lot of apostrophes and quotes which end up closing the quotes in the onclick
attribute.
Update 1
This particular situation is within a "return" of jquery DataTables that are loaded by ajax. Since the JSON varies for each item, I am unable to use addEventListener (please correct me if I'm mistaken).
I specifically require the getJsonObj()
function to trigger a modal displaying all the information inside.
{data: null,
render: function (data, type) {
const json = JSON.stringify(data);
console.log(json);
return `<a onclick="event.preventDefault();getJsonObj(${json})"style='cursor: pointer' id='modalApp' class='orange-link uk-text-bold uk-text-uppercase'>${data.full_name}</a>`;
},
}
The current output looks like this:
https://i.stack.imgur.com/Sxcci.png
Any suggestions on how I could resolve this issue and successfully send the JSON without any complications?
Update 2
To clarify, I am not utilizing any frameworks apart from javascript, jquery, and Jquery datatables in this scenario.