0
我有這個問題,我的網站NIVO滑塊不會AJAX調用後正確加載
我的主要頁面結構是從這個數組這個
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var escapedHash;
function findHash() {
if(window.location.hash) {
//$("#content").html("Loading...");
escapedHash = window.location.hash.replace("#!", "");
//alert(escapedHash);
$.get("data.php?_escaped_fragment_=" + escapedHash, function(data) {
$("#content").html(data);
});
}
}
$(document).ready(function() {
findHash();
});
$(window).bind('hashchange', function() {
findHash();
});
</script>
</head>
<body>
<ul id="nav">
<li><a href="#!page-1">Page-1</a></li>
<li><a href="#!page-2">Page-2</a></li>
...
<li><a href="#!page-n">Page-n</a></li>
</ul>
<div id="content"></div>
</body>
</html>
這個負載數據data.php
<?php
$hash_frag = $_GET['_escaped_fragment_'];
$content = array(
"page-1" => 'content page 1',
"page-2" => 'content page 2',
...
"page-n" => 'content page n'
);
if(isset($hash_frag)) {
echo $content[$hash_frag];
}
?>
Nivo滑塊位於此頁面的其中一頁,如果我刷新了頁面URL /#!page-n(其中page-n包含滑塊),那麼所有內容都可以正常工作。
只要我打電話給另一頁,一切都如預期從另一頁加載內容並替換滑塊。好吧,一切都好。
現在,如果我嘗試從另一個頁面加載滑塊,它只是不會加載,或更好的它會進入div但沒有顯示。我已經鏈接了點擊nivo.slider的初始化,我試圖把它放在數組或主頁上...沒有區別。
有人能幫我解決這個巨大的謎團嗎?
感謝滿口 埃馬努埃萊
您沒有導入NIVO CSS和JS – mgraph 2012-02-27 13:04:45
我做導入JS ...但我忘了css !!!!謝謝 :) – manujj88 2012-02-28 05:02:58