admin管理员组文章数量:1422205
When calling displayBarNotification(stringIPass, 'success', 3500)
of nopmerce
originally defined in publicmon.js
seems the call fails when stringIPass
contains newlines
.
The error on the client-side was something like
Unexpected line break in a string literal
I tried replacing the C#
newline character in the ajax function to the js equivalent and it worked. However, I intend to keep the "newlines" for readability reasons. What approach would you suggest?
Pardon me for the lack of the exact error expr. but it's because I'm currently not at work. I will update tomorrow if necessary.
When calling displayBarNotification(stringIPass, 'success', 3500)
of nopmerce
originally defined in public.mon.js
seems the call fails when stringIPass
contains newlines
.
The error on the client-side was something like
Unexpected line break in a string literal
I tried replacing the C#
newline character in the ajax function to the js equivalent and it worked. However, I intend to keep the "newlines" for readability reasons. What approach would you suggest?
Pardon me for the lack of the exact error expr. but it's because I'm currently not at work. I will update tomorrow if necessary.
Share Improve this question edited Feb 12, 2020 at 18:09 Trevor 8,0046 gold badges33 silver badges52 bronze badges asked Feb 12, 2020 at 18:04 OnionOnion 311 silver badge7 bronze badges 2- developer.mozilla/en-US/docs/Web/JavaScript/Reference/… – Teemu Commented Feb 12, 2020 at 18:06
- You can use the javascript scape function first – Hackerman Commented Feb 12, 2020 at 18:10
1 Answer
Reset to default 6Official documentation:
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them.
Use back-ticks ( ` ) to introduce a template literal:
var example = `
this
is
a
test
`;
console.log(example);
本文标签: javascriptPassing a multiline string as parameter to js functionStack Overflow
版权声明:本文标题:javascript - Passing a multiline string as parameter to js function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744680784a2619393.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论