xhtml页面代码如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Jquery菜单
-
我是菜单2
- 我是子菜单3
- 我是子菜单4
<!--点击菜单时,在div中装载页面中的内容-->
需要在content这个div中装载 我是子菜单1中id指向的html页面,这两个页面是在一个路径下的,对应的jquery代码如下
$(".cmenu > li").click(function(){
var html= $(this).children("a").attr('id');
$("#content").load(html);
});
在Chrome浏览器报错
OPTIONS file:///D:/js/IdeaProjects/JqueryTrain/web/aaa.html No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. jquery.js:2806
XMLHttpRequest cannot load file:///D:/js/IdeaProjects/JqueryTrain/web/aaa.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
在Firefox中报错
SyntaxError: An invalid or illegal string was specified
div.innerHTML = wrap[1] + elem + wrap[2];
不知道是跨域的问题还是什么,请大神赐教!