Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 解析jquery中的新行_Javascript_Jquery_Parsing - Fatal编程技术网

Javascript 解析jquery中的新行

Javascript 解析jquery中的新行,javascript,jquery,parsing,Javascript,Jquery,Parsing,我最近询问并回答了这个问题,它停止了字符串文字错误的问题,但是现在它导致了另一个问题 $(document).ready(function() { $("#message-list .message").click(function() { var msg_id = 1; msg_id = $(this).attr('id').split('-')[1]; $.ajax({ type: "GET",

我最近询问并回答了这个问题,它停止了字符串文字错误的问题,但是现在它导致了另一个问题

$(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);


            }
        });
    });


});
这是字符串解析成的jquery函数(确切地说是json.copy),也是问题发生的地方。在我前面的问题中创建json字符串时,我们删除了\r中的任何字符串,因为它们没有解析出来并用\n转义。但是,我现在遇到了在屏幕上打印新行的问题,\n并且需要在此函数中找到一种方法,以便在不再次导致未终止的字符串文字错误的情况下对其进行解析


\up>这是一个快速而肮脏的黑客攻击,但它也会很快:为什么不把“
\n
”替换为“

”?

我想我不明白:)你能发布一下msg的样子吗?消息所有\n\n\n\n\n\n\n\n在\n\n\n新出现的json字符串是:{“标题”:“再次测试”,“复制”:“所有\\n\\n\n\\n\n管理员\\n\\n\n\\n\nat\\n\\n\n新建”,“重要性”:“立即阅读”,“日期”:“2009-09-22 13:12:22”}