Cross-Origin Request Blocked: Stumbleupon Share Count - json

4 replies
I want to show share counts from StumbleUpon on my website. Its work great with Facebook but with StumbleUpon I am getting following error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.stumbleupon.com/services/...dpress/?p=1118. This can be fixed by moving the resource to the same domain or enabling CORS.
Code:
<script>  $.ajax({
 url: 'http://www.stumbleupon.com/services/1.01/badge.getinfo?url=<?php the_permalink(); ?>',   success: function(data){
 var count = data[0]['count'];
 $("#dd").html(count);
 alert(data);
 $.ajax
 ({
 type: "POST",
 //cache: false,
 url: "post.php",
 data: { stats: count, paralink:'<?php echo the_permalink(); ?>', social:'2' },
 success: function(data) {
 },
 dataType: 'json'
 });
} });     </script>
I am using WordPress...
Please Help Me!
#blocked #count #crossorigin #json #request #share #stumbleupon
  • Profile picture of the author geekSoftware
    Here is working code:

    HTML Code:
    <html>
    <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://kindlebookspromotion.com",
                    success: function(data) {
                        $("#response").html(data);
                    }
                });
            }); 
        </script>
    </body>
    </html>
    {{ DiscussionBoard.errors[9856453].message }}
  • Profile picture of the author Ramesh8248
    I am getting this error:

    SyntaxError: expected expression, got '<'
    <!DOCTYPE html><html><head><link rel="shortcut icon" href="/
    {{ DiscussionBoard.errors[9856550].message }}
    • Profile picture of the author geekSoftware
      That problem can only occur if you didn't copy exactly what I've written for you or you've added some characters you shouldn't. Please check your code.
      {{ DiscussionBoard.errors[9861098].message }}
  • Profile picture of the author kingjpm
    I was getting the same error with Firefox jQuery Ajax request... had to do with

    http:// - did not work
    http://www. - worked

    same domain name too ???

    Still investigating.. now

    possible bug
    Signature
    RogueDen.com
    {{ DiscussionBoard.errors[9862170].message }}

Trending Topics