What I want to do specifically is get the Vimeo thumbnail image by grabbing the json data returned by a request. I can't use jquery due to the javascript file being a small remote file that the user calls and jquery would increase its size many many times.
I have looked and everything seems to be talking about jquery or getting it in another language (php for instance).
I have found I need to do this so far:
var script = document.createElement('script');
script.src = theUrlToMakeTheRequest;
document.getElementsByTagName('head')[0].appendChild(script);
I am not sure what I need to make the callback and not sure what I need to do to be able to use the url that gets appended.
From vimeo's documentation
http://vimeo.com/api/docs/simple-api
It looks like you can put a ?callback=myfunction parameter on the end of the url to do a jsonp type of callback. So your code would maybe look something like this.
function myfunction(data) {
alert(data);
}
var script = document.createElement('script');
script.src = theUrlToMakeTheRequest + '?callback=myfunction';
document.getElementsByTagName('head')[0].appendChild(script);
Their downloads page looks to have examples for just what you are trying to do. http://vimeo.com/api/docs/downloads
You can do it with a raw XMLHttpRequest,
Or for a small lightweight library that can do it check out zepto.js
If you just include zepto.js and ajax.js from... https://github.com/madrobby/zepto/tree/master/src
You would have a JQuery compatible solution in 30k uncompressed javascript (probably < 4k minified)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With