过去几天我一直在调查这个问题,无法弄清楚。下面的代码根据当前页面类搜索外部文件中的内容,然后将内容加载到页面上的任何匹配的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