Any time I use \n
anywhere in javascript/jQuery the browser throws
uncaught syntaxerror: unexpected token illegal
I found ways to work around adding new lines without using \n
, but I can't find a work around to read the \n
from a textarea without using \n
. I am using a mac pro mavericks with the chrome browser version 36. The code is output from a php script from a linux server. I have also tried in firefox and get an equivilent error.
Examples include:
var line = $('#textareaid').val().split("\n");
var line = $('#textareaid').val().split("\r\n");
var some = "This is\nsome text";
All of the examples have the error as well as any other use of \n
. I have been unable to find any reference to \n
not working, but plenty of examples of its use.