let urlPath = window.location.pathname.split("/"),
idFromUrl = urlPath[2],
dataEndpoint = "/bulletins/" + idFromUrl + "/data";
$.ajax({
url: dataEndpoint,
type: "get",
dataType: "html",
success: function (data) {
let dataArray = data.replace(/"/g, '"');
console.log(dataArray);
}
});
I need to extract the content from an HTML page. The content is very basic - just a simple "array" in plain text format, causing JavaScript to treat it as a string instead of an array when retrieved. This is the content of that HTML page:
[{"sermontitle":"test","welcome":"test","_id":"52e7f0a15f85b214f1000001"}]
If I don't replace the "
's, the console.log
output will be
[{"sermontitle":"test","welcome":"test","_id":"52e7f0a15f85b214f1000001"}]
My question now is how can I convert this HTML string (already in "array" form) into an actual array?