What s the right way to decode a string that has special HTML entities in it

0 votes

Let's say I submit a service request and receive the following JSON response:

{
    "message": "We're unable to complete your request at this time."
}

All I know is that I want to decode that apostrophe; I have no idea why it is encoded that way (&#39').

Here is a jQuery-based method that sprang to mind:

function decodeHtml(html) {
    return $('<div>').html(html).text();
}

But that looks (very) clumsy. What might work better? Exists a "correct" approach?

Jul 8 in HTML by Tejashwini
• 1,660 points
8 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In HTML

0 votes
0 answers

How to get the entire document HTML as a string?

Is there a way in javascript to ...READ MORE

Jun 3 in HTML by Tejashwini
• 1,660 points
19 views
0 votes
0 answers

how to create a HTML5 video element without it being shown in the page?

how is it possible to dynamically create ...READ MORE

Jul 5 in HTML by Tejashwini
• 1,660 points
14 views
0 votes
0 answers

How to re-enable right click so that I can inspect HTML elements in Chrome?

I am currently seeing a web page ...READ MORE

Jul 21 in HTML by Ashwini
• 1,160 points
9 views
0 votes
0 answers

Get the query string value and display it in my html page

I can see the query string values ...READ MORE

Jul 21 in HTML by Ashwini
• 1,160 points
24 views
0 votes
0 answers
0 votes
0 answers

Is there a way to change the color of the placeholder text?

I tried to change the placeholder color ...READ MORE

Jul 4 in HTML by Tejashwini
• 1,660 points
9 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,500 points
308 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,740 points
8,878 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,740 points
15,869 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12, 2020 in JQuery by Niroj
• 82,740 points
1,302 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP