Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 3rd Feb 2015, 04:23 AM   #1
Active Warrior
 
Ramesh8248's Avatar
 
Join Date: 2011
Location: India
Posts: 38
Thanks: 9
Thanked 2 Times in 1 Post
Default
Cross-Origin Request Blocked: Stumbleupon Share Count - json
Share on: 
fb share twitter share gplus share more share

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!

Ramesh8248 is offline  
Unread 3rd Feb 2015, 05:32 AM   #2
Active Warrior
Registered Member
 
Join Date: 2013
Posts: 58
Thanks: 4
Thanked 16 Times in 12 Posts
Default
Re: Cross-Origin Request Blocked: Stumbleupon Share Count - json
Share on: 
fb share twitter share gplus share more share

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>
geekSoftware is offline  
Unread 3rd Feb 2015, 06:47 AM   #3
Active Warrior
 
Ramesh8248's Avatar
 
Join Date: 2011
Location: India
Posts: 38
Thanks: 9
Thanked 2 Times in 1 Post
Default
Re: Cross-Origin Request Blocked: Stumbleupon Share Count - json
Share on: 
fb share twitter share gplus share more share

I am getting this error:

SyntaxError: expected expression, got '<'
<!DOCTYPE html><html><head><link rel="shortcut icon" href="/

Ramesh8248 is offline  
Unread 5th Feb 2015, 04:22 AM   #4
Active Warrior
Registered Member
 
Join Date: 2013
Posts: 58
Thanks: 4
Thanked 16 Times in 12 Posts
Default
Re: Cross-Origin Request Blocked: Stumbleupon Share Count - json
Share on: 
fb share twitter share gplus share more share

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.
geekSoftware is offline  
Unread 5th Feb 2015, 01:54 PM   #5
Active Warrior
 
Join Date: 2014
Posts: 44
Thanks: 1
Thanked 6 Times in 6 Posts
Default
Re: Cross-Origin Request Blocked: Stumbleupon Share Count - json
Share on: 
fb share twitter share gplus share more share

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

RogueDen.com

Last edited on 5th Feb 2015 at 01:57 PM. Reason: more info
kingjpm is offline  
Closed Thread


Bookmarks

Tags
blocked, count, crossorigin, json, request, share, stumbleupon


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 02:16 PM.