jQuery Ajax响应头从Echonest请求返回空字符串

时间:2013-12-08 21:42:01

标签: jquery ajax spotify

我正在使用 jQuery Echonest 发出 Ajax 请求,因为您可能知道Echonest会返回一些标头以查看速率限制。我尝试了所有我知道的阅读标题,但我无法获得任何标题。

这是我的代码:

$.ajaxSetup({traditional:true, cache: false});
                    url = 'http://developer.echonest.com/api/v4/song/profile?api_key=' + api_key + '&callback=?';
                    var req = $.getJSON(url,
                        {
                            id : songID,
                            format: 'jsonp',
                            bucket:['audio_summary']
                        }).done(function(data, status, resp){

                           console.log(resp.getAllResponseHeaders())
                           console.log(resp.getResponseHeader('X-Ratelimit-Limit'))
                        });

这是回复的屏幕截图:

enter image description here

我正在尝试阅读 X-Ratelimit-Limit

由于

1 个答案:

答案 0 :(得分:1)

我很确定没有办法从jsonp请求中获取头文件,但该服务看起来像json,所以改为执行json请求。

相关问题