我有一個頁面,通過ajax從其他文件獲取內容,它工作得很好,但是當通過地址欄導航時,它不起作用,因爲事件只在點擊時觸發。我搜查了,但我找不到適合我需要的解決方案。我已經給了我的代碼。有人幫忙。ajax內容的URL導航
<a href="#profile" onclick="profile()">Profile</a>
<div id="home-content" class="container-fluid"></div>
<script>
function profile(){
$.ajax({
type: "POST",
url: "functions.php",
data: {action:profile},
success: function(response)
{
$('#home-content').html(response);
}
});
}
</script>
所有我想要的是,當我像家/#的個人資料,個人資料頁已經被加載輸入地址,也應該是可導航的,與「個人資料」網頁歷史記錄條目
工作只有在的onclick ...具有因您使用的onclick事件僅 – Arun 2015-03-03 04:56:31
不然。在身體的onload調用函數<正文onload =「profile()」> – Arun 2015-03-03 04:58:03