過去幾天我一直在調查這個問題,無法弄清楚。下面的代碼根據當前頁面類搜索外部文件中的內容,然後將內容加載到頁面上的任何匹配的ID中。它適用於Chrome,Firefox,IE9,但最近停止在IE8中工作,我無法弄清楚爲什麼。任何想法將不勝感激。.load在IE8中不工作
HTML看起來像準備
$("div.shared").each(function(){
var Body = $(document).find("body");
var contentID = ("#" + $(this).attr("id"));
var pathname = ""
if(Body.hasClass("pigman")){
var pathname = "/dev/jmsracing/content/pigman/shared-content-include.html"
} else if(Body.hasClass("marion-arts")){
var pathname = "/dev/jmsracing/content/marion-arts/shared-content-include.html"
} else if(Body.hasClass("jms")){
var pathname = "/dev/jmsracing/content/jms/shared-content-include.html"
alert('hello');
}
$(contentID).load(pathname + " " + contentID);
});
你錯過了'var pathname =「」'是你運行的代碼中的錯誤? – KTastrophy
控制檯中是否存在錯誤? Ajax請求是否正確? – epascarello
可能會有這幫助:http://stackoverflow.com/questions/1061525/jquerys-load-not-working-in-ie-but-fine-in-firefox-chrome-and-safari – Jai