1、div显示Django返回的\n
<div id="nlpresult_div" ></div>
$.get('/show_nlpresult/',{
'nlpresultid':id
},function (ret) {
console.log('refresh',ret.content)
var html = ret.content.replace(/\n/g, "<br>");
document.getElementById('nlpresult_div').innerHTML = html;
})
2、textarea 显示Django返回的\n单引号,双引号
<textarea id="mydevinfo" class="form-control" rows="8">
engine = 'x30'
appId = "MB-SYXYYZSX10R328-0001"
clientId = '84267A0CB45C'
deviceId = '84267A0CB45C'
accessToken = "d6fb44e630d04e3285b152d2742e919e"
sign = "05b3539222a1b49ea2b3033ff8304bdc"
familyId = ''
appVersion = '1.9.5'
</textarea>
<script language="javascript" type="text/javascript">
console.log('zhe','{{devinfo|escapejs}}')
if ('{{devinfo|escapejs}}' != '')
document.getElementById("mydevinfo").value = '{{devinfo|escapejs}}'
}
</script>