问题描述
我正在解决对Vimeo API的jQuery ajax调用的问题,该调用在工作了一段时间后于上个月左右开始失败.
I am troubleshooting a jQuery ajax call to the Vimeo API that started failing in the last month or so after having worked for a while.
// Url ends up like "https://www.vimeo.com/api/v2/video/123456789.json?callback=?"
var url = _thumbnailUrl + vimeoId + '.json?callback=?';
$.getJSON(
url,
{ format: "json" },
function (data)
{
// Do Stuff after getting data
}
);
我的猜测是,?callback =?"原本是要强制返回JSONP,但由于某种原因而不再起作用,并返回以下错误.我在Vimeo网站上看不到任何有关API更改的信息,但也许他们已经删除了jsonp支持.
The my guess is that the "?callback=?" was forcing a JSONP return but for some reason that no longer works and returns the following error. I cannot see any information on the Vimeo site about any changes to the API but perhaps they have removed the jsonp support.
text: "parseerror"
error: "jQuery35106413737095079624_1612470990268 was not called"
如果我删除了?callback =?",它在PostMan中可以正常工作(因为您在那里看不到CORS问题),但是在浏览器中它会出现以下错误:
If I remove the "?callback=?", it works fine in PostMan (as you do not see CORS issues there) but in the browser it errors with:
Access to XMLHttpRequest at 'https://www.vimeo.com/api/v2/video/123456789.json'
from origin 'https://www.myurl.com' has been blocked by CORS policy:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
我尝试了很多方法,包括将格式重新格式化为直接的$ .ajax调用,并在ajax调用上切换各种属性,但是没有找到解决方法.
I have tried a bunch of things, including re-formating as a straight $.ajax call and switching out various properties on the ajax call, but have not hit on a solution.
还有其他人看到此Vimeo问题吗?有关如何使其正常工作的任何建议?
Has anyone else see this Vimeo issue? Any suggestions on how to get it to work?
推荐答案
我刚遇到此问题.摆脱了jsonp的东西,现在工作正常.
I just encountered this issue. Got rid of the jsonp stuff and now it works fine.
视频api链接可直接在浏览器中访问. https://www.vimeo.com/api/v2/video/302379615.json 我没有遇到任何CORS问题.
Video api links are accessible directly in the browser.https://www.vimeo.com/api/v2/video/302379615.json I didn't encounter any CORS issues.
$.ajax({
type: 'GET',
url: '//vimeo.com/api/v2/video/' + video.id + '.json',
dataType: 'json',
success: function(data) {
console.log(data);
}
});
这篇关于Vimeo API JsonP问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!