我菜鳥,當談到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