【发布时间】:2016-08-09 20:06:38
【问题描述】:
$(document).ready(function(){ // load jQuery 1.5
function loadfail(){
alert("Error: Failed to read file!");
}
function parse(document){
$(document).find("el").each(function(){
var optionLabel = $(this).find('text').text();
var optionValue = $(this).find('value').text();
$('#el').append(
'<option value="'+ optionValue + '">' + optionLabel + '</option>'
);
});
}
$.ajax({
url: "ednlevel.xml", // name of file with our data - link has been renamed
dataType: 'xml', // type of file we will be reading
success: parse, // name of function to call when done reading file
error: loadfail // name of function to call when failed to read
});
});
上面的代码在 Firefox 上运行良好,但在 chrome 或 Internet Explorer 上无法运行。它有什么问题?
【问题讨论】:
-
我收到“无法读取文件”的错误
-
按 F12 获取错误日志并检查
-
它会帮助您告诉我们什么不起作用。你看到了什么,你期望看到什么。
标签: javascript jquery google-chrome