Some of the records I'm bringing back from the database include an apostrophe.
Various records have a name like the following:
CC CHÂTEAU D'IF
Inspecting the element, the data-attribute looks like this:
data-vesselname="CC CHÂTEAU D" IF'
I need the data-attribute to look like this:
data-vesselname="CC CHÂTEAU D'IF"
Here is the ajax call:
$.ajax({
url: 'api/searchVoyageInfo.php',
type: 'POST',
data: '',
dataType: 'html',
success: function(data, textStatus, jqXHR){
var jsonObject = JSON.parse(data);
var table = $('#example1').DataTable({
"data": jsonObject,
"columns": [{
"data": "",
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol)
{
$(nTd).html("<a href='#' title='Edit Account' class='modAccount'
data-vesselname='"+oData.VESSEL_NAME+"'>Edit</a>");
}
},
{ "data": "ANOTHER_COLUMN" },
{ "data": "ANOTHER_COLUMN" },
// SEVERAL MORE COLUMNS
]
});
I removed a lot of code that wasn't necessary for this question. You can see the data-vesselname attribute above. The problem seems to occur there.
I tried to do the following:
data-vesselname='"+escape(oData.VESSEL_NAME)+"'
But upon inspecting the element, I see this:
data-vesselname="CC%20CH%C2TEAU%20D%27IF"