【发布时间】:2013-05-21 00:55:10
【问题描述】:
我正在使用 jquery 1.6.2。我的 ie 控制台中显示的错误是 Unexpected call to method or property access。 jquery.min.js,第 17 行字符 29094。
我在所有现代浏览器上进行了测试,它在控制台上运行良好,没有任何错误,但是在尝试 ie8 时,我的 xml 文件没有加载。我的 ajax 调用是 OKAY,因为 selectXml 开始运行,但不是里面的代码(它不应该有任何问题,因为它在其他浏览器上工作并且我已经进行了 XML 验证),已经挣扎了几个小时。我认为 ie8 不能与 jquery 一起正常工作。
$(document).ready(function() {
$.ajax({
type: "GET",
url: "menu.xml",
dataType:"text",
success: selectXml
});
(我的 selectXml 函数)
function selectXml (xml) {
var xmlDoc = $.parseXML(xml);
console.log(xmlDoc);
var i = 0,
j = 0,
k = 0,
l = 0,
maxCat = $(xmlDoc).find("categorie").length,
maxPage = 14,
numPlate = 0,
numSection = 2,
page = 0,
queryXml,
title,
theNo,
thePlate,
thePrice,
theSection;
//for each page divide it in 2 sections
for(i=1; i<=maxPage; i++){
if( j < maxCat){
//for each sections add the title and left, right section
//for each left right section, fill up the dishes
for(k=0; k<numSection; k++){
queryXml = $(xmlDoc).find('categorie').eq(j);
title = queryXml.find("title[lang=" + jQuery.fn.language + "]").text();
numPlate = queryXml.find('plate').length;
$('#menu'+ i).append('<section></section>');
$('section').eq(j).append('<div class="menuTitle"><h1>'+ title +'</h1><div class="ribbon"></div></div><div class="menuLeft"><ul></ul></div><div class="menuRight"><ul></ul></div>');
theSection = $('section').eq(j);
for(l=0; l<numPlate; l++){
if(l< (numPlate/2)){
theNo = queryXml.find('plate').eq(l).find('number').text();
thePrice = queryXml.find('plate').eq(l).find('price').text();
thePlate = queryXml.find('plate').eq(l).find('description[lang='+jQuery.fn.language+']').text();
//console.log(thePlate);
$('section').eq(j).find('.menuLeft ul').append('<li><span class="itemNumber">' + theNo +'</span><span class="itemName">'+ thePlate+'</span> <span class="itemPrice">'+ thePrice+'</span></li>');
}
else {
theNo = queryXml.find('plate').eq(l).find('number').text();
thePrice = queryXml.find('plate').eq(l).find('price').text();
thePlate = queryXml.find('plate').eq(l).find('description[lang='+jQuery.fn.language+']').text();
$('section').eq(j).find('.menuRight ul').append('<li><span class="itemNumber">' + theNo +'</span><span class="itemName">'+ thePlate+'</span> <span class="itemPrice">'+ thePrice+'</span></li>');
}
};
numPlate = $(this).find('plate').length;
j++;
}
}//end if
}//end for
}
【问题讨论】:
-
可以用非缩小版替换jQuery脚本文件吗?这将使调试更容易。
标签: jquery xml internet-explorer-8