Home  >  Article  >  Web Front-end  >  The reason why mysql output data is assigned to js variable and unterminated string literal error occurs_javascript skills

The reason why mysql output data is assigned to js variable and unterminated string literal error occurs_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:26:361922browse

Read certain text data from mysql and pay it to js variables such as

Copy code The code is as follows:




But I found that the unterminated string literal error was always reported under Firefox. Copy that text to txt and open it. You will find several black squares. It turns out that they are mysql line break marks. n, in txt it cannot be displayed correctly because it uses double bytes, so 2 black squares are displayed.

Solution: When returning this data from the server, remove rn

$value=str_replace("rn","",$value)


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn