我有一個頁面,點擊邊欄中的鏈接時加載信息段。使用外部鏈接自動加載頁面+ ajax調用(使用Jquery)
http://www.youarehere.im/other-financial-services.html
所有的工作正常。
我也想鏈接到index.html文件中的這個頁面,但是自動加載相關段落,而不是默認狀態。
因此,在主頁上,「accounts」鏈接加載「other-financial-services.html」,並自動向服務器請求ajax調用「accounts」鏈接。
任何想法?我知道這個jquery代碼片段是完全錯誤的,但我對前端腳本非常陌生,並且在黑暗中拍攝!
HTML:
<div class="box accounting"><h2><a id="service_accounts">Accounting</a></h2></div>
JQuery的:
$(document).ready(function() {
$.ajaxSetup({
cache: false
});
var ajax_load = "<img src='img/load.gif' alt='loading...' />";
var load_services = "other-financial-services.html";
var accounts = "accounts.php";
$('#service_accounts').click(function() {
$.get(load_services).load(accounts);
});
});
在您的示例頁面URL工具條不FF8爲我工作。 –
僅供參考:您的元內容標籤未關閉,並且您在ajax.js(第46行,'.get(load_services).load(accounts);')中導致菜單無法在FF8和IE9中工作 – syserr0r
Rory,感謝您在meta標籤上的單挑。我知道Ajax.js在我發佈時已經破裂,現在已經修復。 –