我正在尝试使用以下代码获取我的 Instagram 供稿
I am trying to get my instagram feed with the following code
$.ajax({
url: 'https://api.instagram.com/v1/users/xxxxxxx/media/recent/?access_token=xxxxxxxxxxx',
error: function() {
alert('error');
},
success: function(data) {
alert('yes');
},
type: 'GET'
});
我得到的错误是
请求的资源上不存在Access-Control-Allow-Origin"标头.
有解决办法吗?
Instagram API 支持 JSONP,所以在 url 中添加 &callback=? 并添加 dataType: "jsonp" 到 $.ajax() 调用,如下所示:
Instagram API supports JSONP, so add &callback=? to the url and add dataType: "jsonp" to the $.ajax() call, like below:
$.ajax({
url: 'https://api.instagram.com/v1/users/xxxxxxx/media/recent/?access_token=xxxxxxxxxxx&callback=?',
error: function() {
alert('error');
},
success: function(data) {
alert('yes');
},
type: 'GET',
dataType: "jsonp"
});
这篇关于使用 instagram api 的访问控制允许来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
XHR HEAD 请求是否有可能不遵循重定向 (301 302)Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 请求是否有可能不遵循重定向 (301 302))
NETWORK_ERROR:XMLHttpRequest 异常 101NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 异常 101)
XMLHttpRequest 206 部分内容XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分内容)
XmlHttpRequest onprogress 间隔XmlHttpRequest onprogress interval(XmlHttpRequest onprogress 间隔)
如何修改另一个函数接收到的 XMLHttpRequest 响应文How can I modify the XMLHttpRequest responsetext received by another function?(如何修改另一个函数接收到的 XMLHttpRequest 响应文本?)
XMLHttpRequest、jQuery.ajax、jQuery.post、jQuery.get 有什么What is the difference between XMLHttpRequest, jQuery.ajax, jQuery.post, jQuery.get(XMLHttpRequest、jQuery.ajax、jQuery.post、jQuery.get 有什么区别