Can't get StumbleUpon views for url using AJAX because its API returns text/plain

193 Views Asked by At

I'm trying to get StumbleUpon views for url via $.ajax.

I'm using this api:

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

Full code:

$.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);
    }
});

The problem:

It returns in console "Resource interpreted as Script but transferred with MIME type text/plain" instead the views count + some other things that shouldn't be there

Full error in image: https://i.stack.imgur.com/fRS5j.png

Can I get those views count using only JavaScript?

1

There are 1 best solutions below

0
AudioBubble On

May be this can be helpful...

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