[英]How to fetch meta tags from external URL using jQuery
I have seen that this question has been asked before the but the solution no longer works. 我已经看到在之前已经问过这个问题,但是解决方案不再起作用。 I have tried myself in this Codepen Demo . 我已经在此Codepen演示中尝试过自己。
This is the error that I get : XMLHttpRequest cannot load https://vimeo.com/114166139 . 这是我得到的错误:XMLHttpRequest无法加载https://vimeo.com/114166139 。 No 'Access-Control-Allow-Origin' header is present on the requested resource. 所请求的资源上没有“ Access-Control-Allow-Origin”标头。 Origin ' http://s.codepen.io ' is therefore not allowed access. 因此,不允许访问源“ http://s.codepen.io ”。
My findings so far seem to suggest that I need to do an ajax request to get the link but that did not work either. 到目前为止,我的发现似乎表明我需要执行ajax请求才能获取链接,但这也不起作用。
var videoLink = "https://vimeo.com/114166139";
jQuery.get(videoLink, function(data) {
jQuery(data).filter('meta[name=og:title]').attr("content");
jQuery(".output").append(data);
});
This is not allowed due to CORS. 由于CORS,这是不允许的。
More info about CORS: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing 有关CORS的更多信息: https : //en.wikipedia.org/wiki/Cross-origin_resource_sharing
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.