admin管理员组

文章数量:1355542

When my sql server SP returning string with new line character and in my jsp I pass it to script function and display it in alert box it throws :

function sample(notes){
    alert(notes);
}

Error:
script1015: unterminated string constant 

I can handle it in SP like

REPLACE(BDT.Notes , CHAR(13) + CHAR(10), ''<br/>'' ) as Notes

But is there any way to handle it in script?

When my sql server SP returning string with new line character and in my jsp I pass it to script function and display it in alert box it throws :

function sample(notes){
    alert(notes);
}

Error:
script1015: unterminated string constant 

I can handle it in SP like

REPLACE(BDT.Notes , CHAR(13) + CHAR(10), ''<br/>'' ) as Notes

But is there any way to handle it in script?

Share Improve this question edited Jun 14, 2013 at 11:51 mit asked Jun 14, 2013 at 11:44 mitmit 4,80715 gold badges44 silver badges71 bronze badges 2
  • You can't handle malformed language constructs within a language as it not valid language in that language. Fix up the strings in the jsp before you output them? – Alex K. Commented Jun 14, 2013 at 11:49
  • @AlexK. Can you give sample code? – mit Commented Jun 14, 2013 at 11:53
Add a ment  | 

1 Answer 1

Reset to default 5

try below

 someText = someText.replace(/(\r\n|\n|\r)/gm,"");

see link http://www.textfixer./tutorials/javascript-line-breaks.php

本文标签: javahandle unterminated string constant in javascriptStack Overflow