Search code examples
javascripthtmlangularjsajaxpre

Ajax returned HTML is not rendering in PRE tag


I have a normal http get Ajax call that returns html pre formatted string: '\u000a\u0009\u0009\u0009\u0009\u000a\u0009#07\/04\/2014#\u000a'

I am trying to set this value in pre tag.

HTML: <pre id="preContainer"></pre>

JS: var container = document.getElementById('preContainer');

Work if I pass it in code hardcode value:

container.innerHTML = '\u000a\u0009\u0009\u0009\u0009\u000a\u0009#07\/04\/2014#\u000a';

But do not work if I pass directly the ajax returned object (Angular JS GET Call):

httpFactory.getHTML(..id..).success(function (emailHTML, status) {

            var container = document.getElementById('preContainer');
            container.innerHTML = emailHTML;                
        });

Both the hardcode value and emailHTML value are exactly same. But in later it's not formatting in PRE tag. Any idea Why ?


Solution

  • I just tried jquery Get call and pre tag is rendering HTML fine. Somehow its not working with Angular JS http call.