html decode in jquery

Hi Experts

My jQuery result is printing html result encoded. I need it decoded.
I meant my result as follows:

< is coming as &lt;
> is coming as &gt;

But I wanted to print my results as <> not &lt; &gt;


My code is:

$('.bkexample').text('<!-- Activity name for this tag: Edfrgg_Werrfg_Vwrrr --><script type=\'text/javascript\'>var axel = Math.random()+""; var a = axel * 10000000000000; document.write(\'<img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=' + totalbkvalue2  + '; ord=' + Math.random()*1000000+ '?" width=1 height=1 border=0/>\');</script><noscript><img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=' + totalbkvalue2 + ';ord=' + Math.random()*1000000+ '?" width=1 height=1 border=0/></noscript>');

Open in new window



Its is resolving as:

DIV id="" class="bkexample" jQuery1380524931708="155">
&lt;!-- Activity name for this tag: Edfrgg_Werrfg_Vwrrr --&gt;&lt;script type='text/javascript'&gt;var axel = Math.random()+""; var a = axel * 10000000000000; document.write('&lt;img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=4350; ord=446043.11582667334?" width=1 height=1 border=0/&gt;');&lt;/script&gt;&lt;noscript&gt;&lt;img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=4350;ord=508730.06413507217?" width=1 height=1 border=0/&gt;&lt;/noscript&gt;
</DIV>

Open in new window



Required Result:
<!-- Activity name for this tag: Edfrgg_Werrfg_Vwrrr --><script type='text/javascript'>var axel = Math.random()+""; var a = axel * 10000000000000; document.write('<img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=4350; ord=446043.11582667334?" width=1 height=1 border=0/>');</script><noscript><img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=4350;ord=508730.06413507217?" width=1 height=1 border=0/></noscript>

Open in new window



Please advise
tia_kamakshiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
you should use the .html function like:
$('.bkexample').html('<!-- Activity name for this tag: Edfrgg_Werrfg_Vwrrr --><script type=\'text/javascript\'>var axel = Math.random()+""; var a = axel * 10000000000000; document.write(\'<img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=' + totalbkvalue2  + '; ord=' + Math.random()*1000000+ '?" width=1 height=1 border=0/>\');</script><noscript><img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=' + totalbkvalue2 + ';ord=' + Math.random()*1000000+ '?" width=1 height=1 border=0/></noscript>');

Open in new window



HTH
Rainer
0
tia_kamakshiAuthor Commented:
It is not printing anything

Even below code is not priniting:

$('.bkexample').html('<script></script>');

but this prints
$('.bkexample').html('test');

Please advise
0
Julian HansenCommented:
$('.bkexample').html('<script></script>');

Open in new window

This won't "print" anything because it does nothing - from an html perspective.
If you inspect the element in Firebug - you should see the script tags.

Does this not do what you want?

$('.bkexample').html('<!-- Activity name for this tag: Edfrgg_Werrfg_Vwrrr --><script type=\'text/javascript\'>var axel = Math.random()+""; var a = axel * 10000000000000; document.write(\'<img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=' + totalbkvalue2  + '; ord=' + Math.random()*1000000+ '?" width=1 height=1 border=0/>\');</script><noscript><img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=' + totalbkvalue2 + ';ord=' + Math.random()*1000000+ '?" width=1 height=1 border=0/></noscript>');

Open in new window

0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Rainer JeschorCommented:
Hi,
it seems that jQuery would strip the script tags to avoid browser security/permission denied errors.
Question: your noscript part would not work as the Javscript Math.Random function should not getting executed if scripting is disabled. Therefore you might be able to simply set the HTML of the div to create the IMG part?
HTH
Rainer
0
tia_kamakshiAuthor Commented:
Thanks for your replies.

My problem is still there. I am not seeing the content printed on browser rather I am seeing it on view source.

I need output as
Required Result:
<!-- Activity name for this tag: Edfrgg_Werrfg_Vwrrr --><script type='text/javascript'>var axel = Math.random()+""; var a = axel * 10000000000000; document.write('<img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=4350; ord=446043.11582667334?" width=1 height=1 border=0/>');</script><noscript><img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=4350;ord=508730.06413507217?" width=1 height=1 border=0/></noscript>

Open in new window


rather than:

DIV id="" class="bkexample" jQuery1380524931708="155">
&lt;!-- Activity name for this tag: Edfrgg_Werrfg_Vwrrr --&gt;&lt;script type='text/javascript'&gt;var axel = Math.random()+""; var a = axel * 10000000000000; document.write('&lt;img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=4350; ord=446043.11582667334?" width=1 height=1 border=0/&gt;');&lt;/script&gt;&lt;noscript&gt;&lt;img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=4350;ord=508730.06413507217?" width=1 height=1 border=0/&gt;&lt;/noscript&gt;
</DIV>

Open in new window


Please advise with the solution
0
Julian HansenCommented:
Try using innerHTML

$('.bkexample')[0].innerHTML = ''<!-- Activity name for this tag: Edfrgg_Werrfg_Vwrrr --><script type=\'text/javascript\'>var axel = Math.random()+""; var a = axel * 10000000000000; document.write(\'<img src="http://riiowk.g.domainname.net/activity;xsp=269291;qty=1;cost=' + totalbkvalue2  + '; ord=' + Math.random()*1000000+ '?" width=1 height=1 border=0/>\');</script>';

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.