【发布时间】:2010-05-17 16:34:56
【问题描述】:
以下代码在 IE8 和 Safari4 中按预期工作,但在 Firefox3.6 和 Chrome 中无法正常工作。所有浏览器都在 Windows 上。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() { $('#tabs').tabs(); });
</script>
</head>
<body>
<div id="tabs">
<ul>
<li><a href="http://www.google.com/">Google</a></li>
<li><a href="http://www.msn.com/">MSN</a></li>
</ul>
</div>
</body>
</html>
好像Firefox和Chrome默认不支持跨域AJAX吧?有什么简单的方法可以在 Firefox 和 Chrome 中开启跨域 AJAX?
【问题讨论】:
-
重新标记和删除 ajax,因为这是 jQuery UI 的问题,而不是 ajax 本身的概念。另外,请查看jqueryui.com/demos/tabs/#Ajax_mode。由于您依赖 AJAX 加载内容,因此 UI 插件需要知道如何进行跨域 XHR(我对此表示怀疑)。