2015-01-09 67 views
0

我試圖通過$.ajax獲得StumbleUpon對url的看法。使用AJAX無法獲得StumbleUpon對url的看法,因爲它的API返回文本/純

我使用這個API:

http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://example.com/ 

全碼:

$.ajax({ 
    type: "GET", 
    url: "http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://example.com/", 
    dataType: "jsonp", 
    success: function(result) { 
     console.log(result.result.views); 
    } 
}); 

問題:

它返回控制檯 「Resource interpreted as Script but transferred with MIME type text/plain」 代替觀點數+其他一些事情不應該有

完全錯誤的圖像:http://i.imgur.com/neIvsMf.png

我能使用只有JavaScript這些意見算不算?

+0

它看起來並不像API支持JSONP或爲此事CORS – Musa 2015-01-09 23:05:29

回答

0

可能這可以幫助...

<head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
</head> 
<body> 
    <div id="response"></div> 
    <script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script> 
    <script type='text/javascript' src="http://www.ajax-cross-origin.com/js/jquery.ajax-cross-origin.min.js"></script> 
    <script type='text/javascript'> 
     $(document).ready(function() { 
      $.ajax({ 
       crossOrigin: true, 
       url: "http://www.stumbleupon.com/services/1.01/badge.getinfo?url=https://mywebsite.com", 
       success: function(data) { 
        $("#response").html(data); 
       } 
      }); 
     }); 
    </script> 
</body> 

+0

它的請求限制.. 。 – brabertaser19 2017-01-30 11:59:39

相關問題