Html Completly Deletes And Ignores Control Characters Out Of A String Which I Got Out Of A Json Response
I have got a little problem. I get a String back in a JSON response which has control characters(\n) in it. 'ClData':' stream TV and films online. O\u0027Dwyer is accused of being
Solution 1:
As far as the browser is concerned the "\n" is just white space and will get ignored. Try enclosing the text in a pre tag to tell the browser it is pre-formatted.
content.innerHTML = "<pre>" + root.CatLong.ClData + "</pre>";
Solution 2:
I have to replace the \n with <br>
like this one guy who deleted his answer pointed out
content.innerHTML = root.CatLong.ClData.replace((/\n/g,"<br>");
Post a Comment for "Html Completly Deletes And Ignores Control Characters Out Of A String Which I Got Out Of A Json Response"