Common sources of unterminated string literal

I would vote for jamtoday's answer if I had the "reputation"

If your data is coming by way of PHP, this might help

$str = str_replace(array("\r", "\n"), '', $str);

Look for linebreaks! Those are often the cause.


Most browsers seem to have problems with code like this:

var foo = "</script>";

In Firefox, Opera and IE8 this results in an unterminated string literal error. Can be pretty nasty when serializing html code which includes scripts.