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

  • Home
  • SEARCH
  • 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 4535602
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:25:34+00:00 2026-05-21T14:25:34+00:00

A CDN I am switching to is charging per text/html content-type request (including AJAX

  • 0

A CDN I am switching to is charging per text/html content-type request (including AJAX requests), so I am converting as many ajax requests away from this content-type as possible.

Many of my ajax requests return HTML. What would be the easiest/best way to still convey this content but without the text/html content-type?

Two options I’m aware of, but wary of:

text/javascript

<div class="style1">smdrager's example content</div>

becomes

var content = '<div class="style1">smdrager\'s example content</div>';

Any single quotes will have to be escaped. Is there any unforseen problems with passing content in a simple variable?

application/json

<div class="style1">smdrager's example content</div>

becomes

{"content" : "<div class=\"style1\">smdrager's example content</div>"}

Any double quotes, which are common will have to be escaped. I feel like this would be safer than the variable approach, but I will have to do more work to escape every double quote than single as with the simple variable approach.

EDIT:

Thought of a third option which is easier than the other two. Anyone have any better?

commented javascript

I thought of this:

<div class="style1">smdrager's example content</div>

becomes

/*<div class="style1">smdrager's example content</div>*/

This works without any escaping. The only thing to change in the content is to remove any other javascript block comments, which really shouldn’t be in ajax’ed content anyway.


Is there any approach or content-type which can get me out of having to escape special characters without risking browsers having trouble with the content-type?

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-21T14:25:34+00:00Added an answer on May 21, 2026 at 2:25 pm

    Me: Can’t you just change the content type, but leave the content the same?

    Asker: Wouldn’t that cause errors? Like as text/javascript it could cause javascript errors couldn’t it?

    Me: Who would complain? javascript isn’t executed by itself just by it’s existance as “text/javascript”. Javascript is executed when it’s in a script tag on a page, or actually explicitely executing from some other javascript that has started. So I reckon if you just ask for the data, regardless of the mimetype, it won’t be parsed or executed unless you pass it through something that tries to do that.

    Asker: David, you are correct. I am converting them to text/plaintext now just to be safe. So far, it seems no other changes are needed which makes this the simplest way to do it.

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

Sidebar

Related Questions

With the Announcement of the Microsoft AJAX CDN a debate arouse this morning about
Do anybody know which CDN Netflix and Hulu use for hosting their content and
I’m using a CDN for the following javascript: https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js For each
I use curl to request MS' jquery cdn, and get the follow response: C:\Documents
I use the Google CDN URL for getting jQuery UI. But when I tested
Is the CDN serivce a part of the Cloud Computing conception?
I have a CDN that is storing media files. Each file I want to
Doesn't using Google CDN for jquery break the rule of not using cross domain
Does it actually matter which CDN you use to link to your jquery file
My employer is blocking the Google CDN domain that provides the jQuery file to

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.