获得Twitter股票数量,响应给出奇怪的输出

时间:2015-11-13 14:32:37

标签: javascript html twitter

//this function is the callback, it needs to be a global variable
        window.readResponse = function (response){
            document.getElementsByTagName('SPAN')[0].innerHTML = response;
        }

        (function(){
            //note the "readResponse" at the end
            $URL = "http://www.google.com/"
            var src = 'http://cdn.api.twitter.com/1/urls/count.json?url=' + $URL + '&callback=readResponse',
            script = document.createElement('SCRIPT');
            script.src = src;
            document.body.appendChild(script);
        })();

以上是我的代码来获取股票数量。但是当我提出请求时,我得到的回应是

function (){ //note the "readResponse" at the end $URL = "http://www.google.com/" var src = 'http://cdn.api.twitter.com/1/urls/count.json?url=' + $URL + '&callback=readResponse', script = document.createElement('SCRIPT'); script.src = src; document.body.appendChild(script); }

我期待response.count的实际分享数量。

我在这里设置了一个演示http://jsfiddle.net/zs1dgs45/5/

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)