parsing new lines in jquery

I've recently asked and had answered [this question](https://stackoverflow.com/questions/1459626/unterminated-string-literal) and it's stopped the issue of the string literal error, however it's now caused another problem $(document).ready(function() { $("#message-list .message").click(function() { var msg_id = 1; msg_id = $(this).attr('id').split('-')[1]; $.ajax({ type: "GET", url: "get_message.php", data: "id=" + msg_id, success: function(msg){ var converter = new Attacklab.showdown.converter(); json = eval("("+ msg +")"); var copy = converter.makeHtml(json.copy); $("#message-details .subject").html(json.title); $("#message-details .importance").html(json.importance); $("#message-details .date").html(json.date); $("#message-details .message").html(copy); } }); }); }); this is the jquery function that the string is parsed into (_json.copy to be exact_) and is where the problem occurs. On creating the json string as in my previous question we removed any \r as they were not parsing out and escaping \n with \\n. However i now have the issue of the new lines printing \n on the screen and need a way within this function to unparse them without causing the unterminated string literal error again. `>_<` EDIT: Message: > all\n\n \n\n advisers\n\n \n\n at\n\n newtown json string for that coming in is : > {"title":"testing again","copy":"all\\n\\n\n\\n\\n\nadvisers\\n\\n\n\\n\\n\nat\\n\\n\nnewtown","importance":"read Now","date":"2009-09-22 13:12:22"}
Guess I wasn't understanding :) Can you post what msg looks like.

以上就是parsing new lines in jquery的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏