【发布时间】:2014-02-19 13:40:45
【问题描述】:
我想请求一个远程 XML 文件。我读过 JSONP 是不编写服务器端代码的唯一方法。我正在尝试使用以下代码请求 XML 文件
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$.ajax({
url: 'http://www.w3schools.com/xml/note.xml',
dataType: 'jsonp',
success: function(dataWeGotViaJsonp){
console.log(dataWeGotViaJsonp);
}
});
})
</script>
</head>
<body>
</body>
</html>
我得到错误:
资源解释为脚本,但使用 MIME 类型 text/xml 传输:“http://www.w3schools.com/xml/note.xml?callback=jQuery1620008313672617077827_1390902958529&_=1390902958534”。 jquery.min.js:18 Uncaught SyntaxError: Unexpected token
非常感谢任何帮助。
【问题讨论】: