以下代碼在IE8和Safari4中按預期工作,但不在Firefox3.6和Chrome中運行。所有瀏覽器都在Windows上。Firefox和Chrome默認不支持跨域AJAX?
<!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?
重新標記和清除阿賈克斯,因爲這是與jQuery的用戶界面,而不是AJAX本身的觀念問題。此外,檢查HTTP ://jqueryui.com/demos/tabs/#Ajax_mode。由於你依賴於AJAX來加載內容,所以UI插件需要知道如何做跨域XHR(我懷疑它是如此)。 – 2010-05-17 20:29:24