If the user enters a newline, it is recorded as ' space ' in the data, but is not a real space.
The program foreground uses Ajax and JSON to return data binding to appear unexpected token illegal
Example:
stored in SQL as
In the ")" and "Guide", the "forest" and "pet" between the actual save is a newline character.
$.ajax ({ URL: ', type: ' POST ', data: {}, dataType: ' text ', success:function (dt) { eval ("DT = "+ dt"; }, error:function () { } });
Unexpected token illegal will appear at Eval. Experience tells us unexpected token illegal is some of the formatting, tags, grammar and other incorrect, incomplete
We click on the **.js in the debug browser to go in, see the JSON no problem. Don't worry, we'll copy the JSON.
Format it on the Bejson website, it's no problem. Passed.
The problem is, look closely, you will find that in the "and", "Lin" and "pet" between the \n--text line break.
It is the culprit.
OK, find the problem, we'll solve it, the method is simple
Replace in stored procedure
Your fields are varchar:REPLACE (field name, CHAR (Ten), ' <br/> ') as [alias]
your field is Text,ntext:replace (CONVERT (VARCHAR (MAX), field name), CHAR (Ten), ' <br/> ') as [alias]
Ps:
CHAR (10) line wrap key \ n
char (13) enter \ r
Unexpected token illegal occurs when newline returns Json,eval in Ajax