jQuery的.load()函数不适用于Chrome? [英] Jquery .load() function isn't working on Chrome?
本文介绍了jQuery的.load()函数不适用于Chrome?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用Jquery的.load()函数。在我看来,它不适用于我的Chrome浏览器,但它在Firefox和Safari上工作... ... $ / b>
我不确定我做错了什么?
请帮助我......
以下是我的代码:
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> ;
< html xmlns =http://www.w3.org/1999/xhtml>
< head>
< title>< / title>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/>
< script type =text / javascriptsrc =js / jquery-1.9.1.js>< / script>
< script type =text / javascriptsrc =js / jquery-ui.js>< / script>
< script type =text / javascriptsrc =js / jquery.min.js>< / script>
< link rel =stylesheethref =css / goldstyle.csstype =text / cssmedia =all/>
< / head>
< body>
< div id =navcontainer>
< script type =text / javascript>
$(document).ready(function(){
$('#navcontainer')。load('nav-menu.html');
});
< / script>
< / div>
< / body>
解决方案
我发现如果您直接在浏览器中打开文件,即 file:///
,它将无法在Chrome中使用,而且您会请参阅以下内容:
加载资源失败:原始空值不被Access-Control-Allow-Origin允许
您需要设置网络服务器,例如WAMP,然后从本地主机运行它
I tried to used the .load() function of Jquery. It seem to me that its not working on my Chrome but its working on Firefox and Safari...
I'm not sure what I did wrong? Please help me....
Here's my code below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<link rel="stylesheet" href="css/goldstyle.css" type="text/css" media="all"/>
</head>
<body>
<div id="navcontainer">
<script type="text/javascript">
$(document).ready(function() {
$('#navcontainer').load('nav-menu.html');
});
</script>
</div>
</body>
解决方案
I found out that if you're directly opening the file in the browser, i.e file:///
it will not work in Chrome, and you'll see something like:
Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin
You need to setup a web-server, like WAMP, and then run it from localhost instead
这篇关于jQuery的.load()函数不适用于Chrome?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文