Deezer API – JSON request error with $ .getJSON

Posted on

Question :

When I try to perform a simple search in the Deezer API (Public Search API without Authentication Key) I get the following error message as a return:

XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

The code used to perform the search:

    function(dados) {


Answer :

To make cross-domain calls, you need to use JSONP, and for the server to know that you expect a JSONP to return, you must add the output=jsonp parameter.

    type: 'get',
    url: "",
    dataType: 'jsonp',
    contentType: "application/json; charset=utf-8",
    jsonpCallback: "jsonCallback",
    beforeSend: function(xhr) {
        // função antes de executar a chamada
    success: function(data,statusText,xhr) {
        // função quando ocorrer sucesso

function jsonCallback (data) {
<script src=""></script>


Leave a Reply

Your email address will not be published. Required fields are marked *