Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AJAX response - escaped html

Explorer ,
Dec 09, 2010 Dec 09, 2010

Hi Folks,

I'm using BBC's glow to make an ajax post to a coldfusion page.

It works fine apart from displaying the results in a div with all the html escaped.

Does anyone know how I can display the results as html?

Is there a coldfusion tag/ function that turns special chars into html?

Many thanks


<div id="alert">

&lt;table width="100%" border="0" cellspacing="5" cellpadding="5"&gt;
  &lt;tr&gt;
    &lt;td&gt;Name&lt;/td&gt;
    &lt;td&gt;Lead&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;

    &lt;td&gt;ABDUL KADIR&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Abigail Clinton&lt;/td&gt;

    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Adrienne Parker&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;

  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Aileen Makohon&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
    &lt;td&gt;Aimee Garbett&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;

    &lt;td&gt;Alison Boughey&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Alison Durman&lt;/td&gt;

    &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Alison Hodgson&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;

  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Amy Harrison&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
    &lt;td&gt;Matthew Harris&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;

    &lt;td&gt;Clare Neill&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Lynne Thompson&lt;/td&gt;

    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Clare Neill&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;

  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Amanda Harris&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
    &lt;td&gt;Amanda Harris&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;

    &lt;td&gt;Amanda Harris&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Amanda Harris&lt;/td&gt;

    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Amanda Harris&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;

  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Matthew Harris&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
    &lt;td&gt;Matthew Harris&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;

    &lt;td&gt;Matthew Harris&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Matthew Harris&lt;/td&gt;

    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Matthew Harris&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;

  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Matthew Harris&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
    &lt;td&gt;Matthew Harris&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;

    &lt;td&gt;Matthew Harris&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Matthew Harris&lt;/td&gt;

    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Amanda Harris&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;

  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Amy Harrison&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
    &lt;td&gt;Amanda Harris&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;

    &lt;td&gt;Amanda Harris&lt;/td&gt;
    &lt;td&gt;0&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt; </div>


527
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Dec 09, 2010 Dec 09, 2010

Without drilling down to the problem - why the characters show up in escaped format, I'll just answer the one question:

No, there is not a function in ColdFusion which unescapes escaped HTML strings. Neither has anyone published such function on cflib.org.

But unescaping is easy with ReplaceList() function. Just have the most typical/probably escaped and unescaped strings in the argument lists, and you'll have yourself a function.

Something like this:

<cfscript>

public function HtmlUnescape(htmlstrin

...
Translate
Enthusiast ,
Dec 09, 2010 Dec 09, 2010

Without drilling down to the problem - why the characters show up in escaped format, I'll just answer the one question:

No, there is not a function in ColdFusion which unescapes escaped HTML strings. Neither has anyone published such function on cflib.org.

But unescaping is easy with ReplaceList() function. Just have the most typical/probably escaped and unescaped strings in the argument lists, and you'll have yourself a function.

Something like this:

<cfscript>

public function HtmlUnescape(htmlstring)

{

     return replaceList(arguments.htmlstring,"&gt;,&lt;",">,<");

     //add any other probable special characters and their encodings also to the list

}

</cfscript>

<cfsavecontent variable="test">

&lt;table width="100%" border="0" cellspacing="5" cellpadding="5"&gt;

</cfsavecontent>

<cfoutput>

original: #htmlcodeformat(test)#

<br>

unescaped: #htmlcodeformat(HtmlUnescape(test))#

</cfoutput>

-Fernis

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 10, 2010 Dec 10, 2010
LATEST

Thanks very much for your reply

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources