I am trying to get the AJAX response from Vimeo, to extract a thumbnail without JQuery. But I am not receiving the response, although if I type the response query (http://vimeo.com/api/v2/video/30408418.json) in to the browser, I am offered to download file and it contains the response data in json format... I have just tried copying the same request into a page where I had the Flickr responses working (with jQuery), and the response is still empty, so I think that this is not a JSONP issue.
heres my code
var vimeoVid= {};
var request = getHTTPObject();
if(request){
var requString="http://vimeo.com/api/v2/video/30408418.json";
request.open('GET',requString,true);
request.onreadystatechange=function(){
if(request.readyState==4){
vimeoVid = JSON.parse(request.responseText);
}
};
request.send();
}
else
{
alert('Sorry, your browser doen\'t support XMLHttpRequest');
}
console.log("vimeoVid");
where
function getHTTPObject(){
if(typeof XMLHttpRequest == "undefined")
XMLHttpRequest=function(){
try{return new ActiveXObject("Msxml2.XMLHHTP.6.0");}
catch(e){}
try{return new ActiveXObject("Msxml2.XMLHTTP.3.0");}
catch(e){}
try{return new ActiveXObject
("Msxml2.XMLHTTP");}
catch(e){}
return false;
}
return new XMLHttpRequest();
}
AJAX doesn't work cross-domain (except for modern browsers and where specifically allowed). You have to use JSONP.
Example URL: http://vimeo.com/api/v2/video/30408418.json?callback=bacon