これは私のコードです:
test.html
<html>
<head>
<title>test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$(window).bind('hashchange', function(){
$('#result').load('test2.html', function(){
alert('Load was performed.');
});
});
});
</script>
</head>
<body>
<a href="#Test1">Test 1</a>
<a href="#Test2">Test 2</a>
<div id="result"></div>
</body>
</html>
test2.html
<h3>This is content from test2.html</h3>
変更で window.hash を使用してロードする特定のページを検出したい。たとえば、ユーザーがhttp://localhost/test.html#test2
.
ページのメイン コンテナー (結果) は、コンテンツを取得するために test2.html への Ajax ロード呼び出しを実行します。この単純なコードを機能させることができません。誰かが私を正しい方向に導くことができれば幸いです。ありがとう。