我菜鸟,当谈到Ajax和jQuery和需要一些帮助......阿贾克斯/ jQuery的问题
以下URL生成一个XML文件,我想我的网页上使用: http://ws.spotify.com/search/1/track?q=foo
当我使用萤火虫似乎没有回来。我做错了什么?
这是我的代码如下所示:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url: 'http://ws.spotify.com/search/1/track?q=foo',
type: 'GET',
contentType: "application/xml; charset=utf-8",
error: function(){
alert('Error loading XML document');
},
success: function(xml){
alert("success");
$(xml).appendTo("#result");
}
});
});
</script>
</head>
<body>
<div id="result">
</div>
</body>
</html>
是在同一个域中的XML文件作为你从它调用它的脚本? – munch 2010-04-22 19:15:59
当你说**没有回来**时,我假设你的意思是你的“成功”回调被调用,但没有数据。是对的吗? – user113716 2010-04-22 19:45:15
纯XML回复将不会显示在浏览器中。 – dacracot 2010-04-22 19:52:27