string having '<br/>' throws unterminated string literal js error.

Posted by kranthi on Stack Overflow See other posts from Stack Overflow or by kranthi
Published on 2011-01-28T15:32:55Z Indexed on 2011/01/28 23:25 UTC
Read the original article Hit count: 154

Filed under:
|
|

Hi All,

I am fetching some data from Db and displaying it in a textarea using jquery in the following way. $('#textareatest').val('<% =teststring %>').It is possible that the string 'teststring' can contain XHTML line breaks(<br/>).whenever the string contains <br/> I am getting the 'unterminated string literal' error.I saw a number of posts considering '\n' as line breaks and suggesting to escape it.I tried to escape the <br/> similarly,but it didn't work.

Could someone please help me with this?

UPDATE:: I've already escaped single quotes. here is an example string test string<br />

Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ASP.NET