我在通过 ajax 调用重新加载的页面上有一个输入框(内容是刷新)。问题是当输入框中有一个单引号时,剩余的值被截断,我该如何解决这个问题?
myVal = <-- its coming dynamically from db and when it contains values like "It's me", next time page reloads It just show "It" in input box
$('#myInput').val(myVal);
//after setting value and doing some other things, this content is reloaded
这是java(服务器端代码)
<input id="myInput" value="<c:if test='${deamer!=null}">${deamer.name}, ${deamer.code}</c:if>' />
当来自服务器端的值包含 ['] 时,代码将失败....