Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6689679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:32:51+00:00 2026-05-26T05:32:51+00:00

I am using jQuery to call a php page (via ajax) that goes to

  • 0

I am using jQuery to call a php page (via ajax) that goes to my server to grab some data. The data is then encoded to json and returned to the page. I am then parsing the json with jQuery. I am having a problem displaying html items that are getting returned. In the json object the piece of data in question is a value to a “description” key. The json gets returned as below:

{ "description" : "Check the Wiki article to see what states require Two-Party Notification. (<a href="http://intranet.clickmotive.com/Wiki/Call%20Recording%20-%20Two%20Party%20Notification%20States.ashx" target="_blank">wiki link</a>)" }

Then i use a simple function that i found on here to decode the html. Then function i’m using is this (i pass the value of the above key through to this function):

function htmlDecode(value){
    return $('<div/>').html(value).text();
}

This decodes the text it to be as follows:

Check the Wiki article to see what states require Two-Party Notification. (<a href="http://intranet.clickmotive.com/Wiki/Call%20Recording%20-%20Two%20Party%20Notification%20States.ashx" target="_blank">wiki link</a>)

This is how i am adding it to the page: (where the ‘description’ variable is being set from the json data)

$("#description").append(htmlDecode(description));

My problem is that it is displaying the full html as text and not as html. So, there is no link being created. What is my problem with this code? I must be missing something. Let me know if you have any questions! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:32:52+00:00Added an answer on May 26, 2026 at 5:32 am

    Your data is double htmlentities() encoded. So there are two ways to solve this problem:

    jQuery

    The thing what you’ve done is almost good:

    function htmlDecode(value){
        return $('<div/>').html($('<div/>').html(value).text()).text();
    }
    

    Or simply call your htmlDecode() method twice as @Dennis mentioned.

    htmlDecode(htmlDecode(description));
    

    JsonML

    I think it would be a better idea to use JsonML instead of simple JSON for this.

    JsonML is a JSON encoding of an XML document (or node), so actually it would fit better for your problem.

    I wrote a JsonML jQuery plugin, which you can fetch form github. You’ll need a PHP JsonML encoder as well, which is easy to write, and I think there should be available implementations as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question: I'm using jquery ajax to call a page that returns some json
Im using jquery to call a page via ajax. I have some jquery functions
I have a script that calls a php page via jquery/ajax. The results would
Using jquery I am calling a php page using an ajax call. I call
Im using arte for jquery to call a page via ajax every 10 seconds.
Whats the best way to pass data to jQuery AJAX Get method via PHP.
I'm making an ajax call using jQuery as below. $.ajax({ type: POST, url: proc.php,
I am sending a json string using JQuery.ajax to a php page where I
I built this website using ajax (via jquery) instead of full page refresh. Right
I just finished coding my first jquery ajax call page. It calls a php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.