动态显示一个js文件到页面上,该怎么解决

动态显示一个js文件到页面上
需求:输入一个js地址,然后将它的源码显示到界面上(不需要执行)。
使用ajax能获取到txt的文件内容(js后缀改为txt),但换成js文件就会报错是什么原因?如何解决

$.ajax({
type: "POST",
url: "./XXX/XX.js,
success: function(msg){
$('body').html(msg.replace(/ /g, "&nbsp;").replace(/\n/g, "<br />"));
},
error:function(XMLHttpRequest, textStatus, errorThrown){
console.log(textStatus);
console.log(errorThrown);
}
});
------解决方案--------------------
$.ajax({
type: "POST",
url: "4.js",
dataType:'text',
success: function(msg){
$('body').html(msg.replace(/ /g, "&nbsp;").replace(/\n/g, "<br />"));
},
error:function(XMLHttpRequest, textStatus, errorThrown){
console.log(textStatus);
console.log(errorThrown);
}
});