Erik

Erik

I'm trying to download some video info using the simple API inside the users browser using xmlhttprequest to present some thumbnails and video details.
But when i do this i get an error saying "[myhostname] not allowed by Access-Control-Allow-Origin", or something similar depending on the browser.

I'm not very into the technical details of this but i believe that is a property you can add in your header to explicitly allow cross domain requests.

I would prefer to not use the JSONP option as it is much harder to control and it opens up for other security issues and problems.

volkan ongun

volkan ongun

hey,

i have the same issue. is there a solution for this, or any workarounds?

actually i'm using json and simple html page. when file is on ftp or local storage, chrome 11 and firefox 3.5 is returning 'Access-Control-Allow-Origin' but safari works when its locally stored but not working with uploaded file.

thanx!

talha kamran

talha kamran

Brad,
Would you be able to help me with the problem with advanced api. JSONP is acting wiered on that. I used a class to encrypt the url to work for OAuth. The urls work fine when i put them in browser but dont work when i do ajax from code.

Please check the link below. I know its not secure but what am i doing wrong. I can't move forward if I can't figure out the reason to a problem. Its been 4 days and I am going nutts now.

Example:
projects.tk-fn.com/examples/VimeoAdvancedCallJSONP.html

LoneIgadzra

LoneIgadzra

That doesn't actually do anything. I've been trying to figure this out too: the callback parameter is not very useful as it can only be the name of a function, and I want to pass a number of parameters into it from the function that initiated the XHR request to the oembed api in the first place (such as where the video should be embedded).

But only jQuery.getScript, passing in the name of a callback bypasses the origin error.

mark reid

mark reid Plus

ok, so i've been having a bit of a look at this today.

as mentioned above, one option is to use jsonp instead of json (in jQuery you set the dataType property to 'jsonp'). in jQ this basically does what brad's suggesting above, by appending ?callback=xxx to the request.

the problem with jsonp in jQuery though is that it only fires a success event, but won't fire errors or timeouts, as mentioned here:

stackoverflow.com/questions/1002367/jquery-ajax-jsonp-ignores-a-timeout-and-doesnt-fire-the-error-event

as a work around, one of the suggestions from that link is to use the jquery-jsonp plugin:
code.google.com/p/jquery-jsonp/

which is almost identical to jQuery's ajax method but enables the use of proper error callbacks, etc.

but surely this can be solved by Vimeo changing their server settings to allow cross-domain json requests?

talha kamran

talha kamran

Guys simple JSONP calls are very simple on Vimeo.
here is a basic call to get information about a channel.
$.getJSON("vimeo.com/api/v2/channel/6513/info.json?callback=?";, function (results) {
num_of_videos_in_channel = results.total_videos; //20 video are pulled in 1 request
});

Brad,
Would you be able to help me with the problem with advanced api. JSONP is acting wiered on that. I used a class to encrypt the url to work for OAuth. The urls work fine when i put them in browser but dont work when i do ajax from code.

Please check the link below. I know its not secure but what am i doing wrong. I can't move forward if I can't figure out the reason to a problem. Its been 4 days and I am going nutts now.

Example:
projects.tk-fn.com/examples/VimeoAdvancedCallJSONP.html

Link: projects.tk-fn.com/examples/VimeoAdvancedCallJSONP.html

Gustavo Ortiz

Gustavo Ortiz

JSONP works just fine with jQuery.

requestConfig = {
url : "vimeo.com/api/v2/video/"; + videoId,
dataType : 'jsonp',
success : function (data) {
console.log(data);
}
}
$.ajax(requestConfig)

This conversation is missing your voice. Please join Vimeo or log in.