XMLHttpRequest无法加载(Soundcloud永久链接)。无法从null发出任何请求

时间:2013-07-10 10:35:34

标签: ajax api soundcloud

我正在访问soundcloud api以获取stream_url。 我已将此代码上传到两个不同的地方:

1)下载无效+ ajax调用失败,出现以下错误:

url:http://download.berlintechno.net/test/indextest.html

2)下载+一切正常

url:http://dl.dropboxusercontent.com/u/26890303/indextest.html

以下代码

<html>
<head>
<title>
</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body >
<div id="results"><a href="https://api.soundcloud.com/tracks/99777114/stream?client_id=fb14c3f2a35b89b556cce18b8614e908" class="btn btn-large scdown">1</a><br>
<a href="https://api.soundcloud.com/tracks/18658191/stream?client_id=fb14c3f2a35b89b556cce18b8614e908" class="btn btn-large scdown" download="Woody @ Licht&amp;Liebe Open Air, Berlin 29-05-2011.mp3">2</a><br>
<a href="https://api.soundcloud.com/tracks/11144882/stream?client_id=fb14c3f2a35b89b556cce18b8614e908" class="btn btn-large scdown" download="Woody + Lodig, Weissgerberlaende Afterparty, 1994 - Vienna.mp3">3 </a><br></div>

<script>
$.ajax({
      type: "GET",
      url: "https://api.soundcloud.com/tracks/99777114/stream?client_id=fb14c3f2a35b89b556cce18b8614e908",
      //beforeSend: function(xhr){xhr.setRequestHeader('Origin', null);},
      success: function(data) {
         console.log(data);
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
         console.log('error: ' +textStatus);
      }
   });
</script>

</body></html>

主机download.berlintechno.net是否受到来自soundcloud api的任何重新启动的影响?

1 个答案:

答案 0 :(得分:0)

download.berlintechno.net引用了这个jQuery库

<script src="http://code.jquery.com/jquery-2.0.3.js"></script>

而dl.dropboxusercontent.com引用了这个jQuery库

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

导致不同的行为。