【发布时间】:2013-07-30 15:44:20
【问题描述】:
我用简单的 ajax 创建了简单的 html 文件。
index.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; Charset=UTF-8">
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<div id="content"></div>
<script>
function show()
{
$.ajax({
url: "2.html",
cache: false,
success: function(html){
$("#content").html(html);
}
});
}
$(document).ready(function(){
show();
setInterval('show()',1000);
});
</script>
</body>
</html>
文件 2.html 与文件 index.html 位于同一目录中。并包含例如:
<p>ssss hkl jh lkh <b>d1111</b></p>
当我在网络服务器上运行 index.html 时,一切正常。但是,如果您在计算机上运行文件 index.html 作为本地文件 ajax 不起作用。如何解决?
【问题讨论】:
-
jquery.js是否包含在index.html旁边? -
您在 Chrome 中吗? Chrome 不允许使用本地 ajax 内容。