Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <p id="url1" style="display:none;">https://api.facebook.com/method/fql.query?query=select%20total_count,like_count,comment_count,share_count,click_count%20from%20link_stat%20where%20url=%27http://google.com%27&format=json</p>
- <div id="result" style="color:green"></div>
- <script>
- var getJSON = function(url) {
- return new Promise(function(resolve, reject) {
- var xhr = new XMLHttpRequest();
- xhr.open('get', url, true);
- xhr.responseType = 'json';
- xhr.onload = function() {
- var status = xhr.status;
- if (status == 200) {
- resolve(xhr.response);
- } else {
- reject(status);
- }
- };
- xhr.send();
- });
- };
- var test = document.getElementById('url1').innerHTML;
- getJSON(test).then(function(data) {
- document.getElementById("result").innerHTML = data[0].total_count; //display the result in an HTML element
- }, function(status) { //error detection....
- alert('Something went wrong.');
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment