Pinterest pins through HTML/JavaScript -
i have been using pins information of pin pinterest.
the following script being used:
<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> whenever xmlhttprequest() method being invoked status returned 0 , xmlhttp.responsetext empty.
but when link opened in browser response correct , has information of pin.
edit:
tried implementing cross domain too. yet status returns 0. new script:
<script type="text/javascript"> function getresponse1() { var xhr = new xmlhttprequest(); var url="https://widgets.pinterest.com/v3/pidgets/pins/info/?pin_ids=308074430730714588"; if ("withcredentials" in xhr) { xhr.open("get", url, true); } else if (typeof xdomainrequest != "undefined") { xhr = new xdomainrequest(); xhr.open(method, url); } else { xhr = null; } alert(xhr.status); var data=xhr.responsetext; } </script> please let me know i'm making mistake. in advance
note: i'm using chrome browser
this general issue, try ajax request different site (cross domain).
this isn't new issue @ all, think here explained , posts provide thoughts possible solutions.
Comments
Post a Comment