简体   繁体   中英

jQuery Ajax response header returns empty string from Echonest request

I am making Ajax request with jQuery to Echonest , as you might know Echonest returns some headers to see the rate limit. I tried everything I know to read headers but I couldn't get any header.

This is my code:

$.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'))
                        });

And this is the screenshot of the response:

在此处输入图片说明

I am trying to read X-Ratelimit-Limit

Thanks

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM