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 7823269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:11:06+00:00 2026-06-02T08:11:06+00:00

I have designed a JSON object that is used as the format of AJAX

  • 0

I have designed a JSON object that is used as the format of AJAX response sending back to the clients of my web app. I am in the process of enhancing it by putting html code into it. But the character escaping required is making me rather uncomfortable due to my lack of precise knowledge and experience on the topic.

I use Python/Django as my server-end language/framework. To get from a Python string literal to a proper HTML node for browsers to consume, with my vague knowledge on character escaping, I guess I would need two stages of character escaping:

  1. Serialize the Python string literal into JSON and escape the characters as required by JSON.
  2. Once the JSON object is received at the client-end, escape the characters as required by HTML. Note that I use jQuery.

Is my view of the above two stages correct? If so, how can I achieve them?

If it’s easier for you to explain with an example. Here is one:

s = '<a href="http://www.foo.com/bar/">"Click Here&Here"</a>'

where s is a Python string literal. And I want to see it become

<a href="http://www.foo.com/bar/">"Click Here&amp;Here"</a>

in the HTML.

  • 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-06-02T08:11:08+00:00Added an answer on June 2, 2026 at 8:11 am

    Do you need to escape it client side? You can do it in Python before encoding it to JSON:

    from cgi import escape
    from json import dumps
    
    ajax_response = dumps(escape('<a href="http://www.example.com/path/location'
                                 '?query=string&more=this#anchor">'
                                 'FooBar & Friends</a>'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the moment we have an AJAX driven site that returns a JSON response
I have designed a menu that consists of a few buttons in several different
I have designed a new web site. I have hosted it online. I want
I have an MVC3 View that's posting back a set of input values via
I have designed this server to broadcast to all clients when it has to
I have a JSON data file that is part of my application (version controlled,
I'm trying to use jQuery and JSON with a C# Web Service that I
Two related ASP.NET Web Service JSON questions here. I'm using a N-tier designed ASP.NET
I have designed a site and my CSS is not loading in FF and
I have designed a page in Fireworks then imported it to Dreamweaver in CSS

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.