| | #1 |
| Active Warrior Join Date: 2011 Location: India
Posts: 38
Thanks: 9
Thanked 2 Times in 1 Post
|
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> Please Help Me! |
| | |
| |
| | #2 |
| Active Warrior Registered Member Join Date: 2013
Posts: 58
Thanks: 4
Thanked 16 Times in 12 Posts
|
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> |
| |
| | #3 |
| Active Warrior Join Date: 2011 Location: India
Posts: 38
Thanks: 9
Thanked 2 Times in 1 Post
|
I am getting this error: SyntaxError: expected expression, got '<' <!DOCTYPE html><html><head><link rel="shortcut icon" href="/ |
| | |
| |
| | #4 |
| Active Warrior Registered Member Join Date: 2013
Posts: 58
Thanks: 4
Thanked 16 Times in 12 Posts
|
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.
|
| |
| | #5 |
| Active Warrior Join Date: 2014
Posts: 44
Thanks: 1
Thanked 6 Times in 6 Posts
|
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 | |
| |
|
| Bookmarks |
| Tags |
| blocked, count, crossorigin, json, request, share, stumbleupon |
| |