返回Json或object,导致bug,使用eval函数处理

来源:互联网 发布:westlife知乎 编辑:程序博客网 时间:2024/06/05 13:34
function news(id){
$.ajax({
type : "POST",
url:"${path}/bulletinNews/newsDetail.do",
        dataType: 'json',//返回数据的类型  
        data:{id:id},
        success:function (data) {
        data=eval('('+data+')');
        $("#newsDetail").html("");
        var html = "<div class='popup_top'><span></span><b class='popup_title'>"+data.title+"</b></div>";
            html += "<div class='popup_main'><div class='popup_txt align_center'>"+data.content+"</div></div>";
            html += "<div class='popup_bottom align_center'><input type='reset' onclick='exit();' value='关闭'/></div>";
            $("#newsDetail").append(html);
        $("#newsDetail").show();
        }
    });

}

data=eval('('+data+')');//通过eval函数对data进行处理

阅读全文
0 0