How to get the value of Codemirror textarea

Try using getValue() instead of getCode().

Pass in an optional argument into getValue(separator) to specify the string to be used to separate lines (the default is \n).


This works fine for me.

editor.getValue()