我在本地system.I一个XML文件可以读取与IE和Firefox运行它的jQuery的文件,但我无法读取使用Chrome和Opera.Where是问题的文件?jQuery的读取XML问题
<!DOCTYPE html>
<html>
<head>
<title>AJAX </title>
<script type="text/javascript" src="jq.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$.support.cors = true;
$.ajax({
type: "GET",
//crossDomain: true,
//contentType: "application/xml",
contentType: "application/xml;charset=UTF-8",
url: "YYYYAAGGu.xml",
//url: "today10.xml",
cache: false,
dataType: "xml",
success: function(xml) {
$(xml).find('Currency').each(function(){
var name = $(this).find("Isim").text()
alert(name);
});
},
error: function(xhr, status, error) {
alert("An error occured: " + status + "\nError: " + error);
}
});
});
</script>
</body>
</html>
任何错误在浏览器控制台? –
刚刚发生错误:错误错误: – Mustafa
这将是从错误处理程序的警报。该请求明显失败,所以应该在控制台的东西(F12工具/萤火虫/等) - 太依赖这哪里是页面类型不匹配,可能跨域失败。如果不在网络观察标签中检查请求响应是否如预期那样。 –