ajax读取文本文件的格式

basey basey 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
本地127.0.0.1用ajax读取文本格式文件,都没有问题。
但在服务器上读取,试了一下,只能读取txt css xml或者可能别的扩展名的文本文件,但扩展名改成别的如ini doc tst等居然读不出。

这个是什么原因呢?有谁碰到过?可能是服务器的配置问题么?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
<script type="text/javascript">
function doAjaxCall(the_request)
{
var request=null;
if(window.XMLHttpRequest)
{
request=new XMLHttpRequest();
}else if(window.ActiveXObject)
{
request=new ActiveXObject("Microsoft.XMLHTTP");
}
if(request)
{
request.open("GET",the_request,true);
request.onreadystatechange=function()
{
if(request.readyState===4)
{
if (request.status == 200 || request.status == 0)
{
document.getElementById("vv").innerHTML=request.responseText;
}
}
}
request.send(null);
}else{
alert("error");
}
}
</script>
</head>

<body>
<input type="button" value="测试" onclick="doAjaxCall('ajax-1.txt');"/>
<div id="vv"></div>
</body>
</html>
...全文
评论 8
收藏 已收藏
分享
返回顶部
basey
Ajax 52,778 成员 25,334 内容