Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Can';使用AJAX无法获取url的StumbleUpon视图,因为其API返回文本/纯文本_Javascript_Jquery_Ajax_Json_Stumbleupon - Fatal编程技术网

Javascript Can';使用AJAX无法获取url的StumbleUpon视图,因为其API返回文本/纯文本

Javascript Can';使用AJAX无法获取url的StumbleUpon视图,因为其API返回文本/纯文本,javascript,jquery,ajax,json,stumbleupon,Javascript,Jquery,Ajax,Json,Stumbleupon,我试图通过$.ajax获取url的StumbleUpon视图 我正在使用此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/", dataT

我试图通过
$.ajax
获取url的StumbleUpon视图

我正在使用此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);
    }
});
完整代码:

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);
    }
});
问题:

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);
    }
});
它在控制台中返回“
资源,解释为脚本,但使用MIME类型text/plain传输”
,而不是视图计数+一些不应该在那里的其他内容

图像中的完全错误:


我可以只使用JavaScript来计算这些视图吗?

这可能会有所帮助

<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>


$(文档).ready(函数(){
$.ajax({
交叉起源:对,
url:“http://www.stumbleupon.com/services/1.01/badge.getinfo?url=https://mywebsite.com",
成功:功能(数据){
$(“#响应”).html(数据);
}
});
}); 

API似乎不支持JSONP或CORS