Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pinterest通过HTML/JavaScript锁定_Javascript_Html_Pinterest_Xmlhttprequest - Fatal编程技术网

Pinterest通过HTML/JavaScript锁定

Pinterest通过HTML/JavaScript锁定,javascript,html,pinterest,xmlhttprequest,Javascript,Html,Pinterest,Xmlhttprequest,我一直在使用从pinterest获取pin信息 以下是正在使用的脚本: <script type="text/javascript"> function getresponse1() { var xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", "https://widgets.pinterest.com/v3/pidgets/pins/info/?pin_ids="+{Pin ID});

我一直在使用从pinterest获取pin信息

以下是正在使用的脚本:

<script type="text/javascript">
    function getresponse1()
    {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", "https://widgets.pinterest.com/v3/pidgets/pins/info/?pin_ids="+{Pin ID});
    alert(xmlHttp.status);
    var data=xmlHttp.responseText;
    var jsonResponse = JSON.parse(data);
    var pin_url="www.pinterest.com/pin/"+pin_id+"/";
    var page_name=(jsonResponse["data"][0].pinner.full_name);
    alert(page_name);
    }
    </script>
请告诉我哪里出错了。提前谢谢


注意:我使用的是Chrome浏览器,这是一个一般性问题,因为您试图向不同的站点发出ajax请求(跨域)


这根本不是一个新问题,我认为它已经得到了很好的解释,本文还提供了一些关于可能的解决方案的想法。

AJAX是异步的,因此您的数据只能通过某种回调来获得

xhr.onload = function() {
    if (xhr.status >= 200 && xhr.status < 400) {
        var data = JSON.parse(request.responseText);
    }
};
xhr.onload=function(){
如果(xhr.status>=200&&xhr.status<400){
var data=JSON.parse(request.responseText);
}
};

您好,谢谢您的回复。我已经为Google plus Posts实现了一个类似的代码,它工作得非常好。我不太精通AJAX。不过我使用的是简单的Javascript。我已经按照您提供的链接中的建议编辑了问题并添加了新代码。请调查一下,让我知道我在哪里犯了错误。非常感谢。
xhr.onload = function() {
    if (xhr.status >= 200 && xhr.status < 400) {
        var data = JSON.parse(request.responseText);
    }
};