简体   繁体   English

使用Ajax调用Deezer API(jquery)-dataType JSON返回null-JSONP返回错误

[英]Calling Deezer API using Ajax (jquery) - dataType JSON return null - JSONP return error

here is my code, i suggest you to test it : 这是我的代码,我建议您对其进行测试:

           function callDeezerAPI() {
                $.ajax({
                    type: 'GET',
                    url: 'http://api.deezer.com/playlist/580739065',
                    dataType: 'jsonp',
                    success: function(data) {
                        console.log(data);
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        console.log(XMLHttpRequest);
                        console.log(textStatus);
                        console.log(errorThrown);
                    }
                });
            }
            callDeezerAPI();

I'm just trying to get the same result as if I'go to http://api.deezer.com/playlist/580739065 and works with these JSON data. 我只是想获得与访问http://api.deezer.com/playlist/580739065相同的结果,并且可以使用这些JSON数据。

When I use JSONP dataType, I can see the data I want through a JQuery error... so I can't use it. 当我使用JSONP dataType时,可以通过JQuery错误看到我想要的数据...因此我无法使用它。

Please let me know if someone knows how to do this using JSON or JSONP (it seems that Deezer API accepts JSONP...). 如果有人知道如何使用JSON或JSONP(似乎Deezer API接受JSONP ...),请告诉我。

Thank you ! 谢谢 !

您必须通过输出参数指定格式:

http://api.deezer.com/playlist/580739065?output=jsonp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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