ajax中的“拒绝访问”错误
在下面的ajax代码中,我收到一条“访问被拒绝”错误消息。有人能在这方面帮助我吗ajax中的“拒绝访问”错误,ajax,Ajax,在下面的ajax代码中,我收到一条“访问被拒绝”错误消息。有人能在这方面帮助我吗 <html> <head> <script type="text/javascript"> function a() { var xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET","load1.txt",true); xmlhttp.onreadystatechange=function() { document.getElemen
<html>
<head>
<script type="text/javascript">
function a()
{
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","load1.txt",true);
xmlhttp.onreadystatechange=function()
{
document.getElementById("hello").innerHTML=xmlhttp.requestText;
}
}
</script>
</head>
<body>
<input type="button" value="hello" onclick="a()"/>
<div id="hello"></div>
</body>
</html>
您已经在代码中表示为requestText,我认为应该是responseText 示例代码
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML= xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
}
</script>
<div id="myDiv">Let AJAX change this text</div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
查看位于的实时示例,错误为u r拒绝访问该特定文件。。检查您是否有访问load1的权限。TXT是的,我有读写权限。:-问题仍然存在,兄弟。@Bivin Ravindran问题仍然存在吗?