<script type="text/javascript"> function Ajax(){ var xmlHttpReq=null; if(window.ActiveXObject){ xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest){ xmlHttpReq=new XMLHttpRequest(); } xmlHttpReq.open("GET","text.php",true); xmlHttpReq.onreadystatechange=RequestCallBack; xmlHttpReq.send(null); function RequestCallBack(){ if(xmlHttpReq.readyState==4){ if(xmlHttpReq.status==200){ document.getElementById("resText").innerHTML=xmlHttpReq.responseText; } } } } </script></head><body><input type="button" value="Ajax提交" onclick="Ajax()" /><div id="resText"> </div></body></html>index.html:21 XMLHttpRequest cannot load file:///F:/%E8%81%8A%E5%A4%A9%E5%AE%A4/text.php. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.Ajax @ index.html:21
2 回答
柠檬酸钠
TA贡献331条经验 获得超534个赞
楼主是不是在本地直接以file:///的格式打开的文件,ajax不支持本地模式哦,还有本地的php文件也跑不起来,没法执行,楼主可以搭建个本地服务器试试
添加回答
举报
0/150
提交
取消