How do we solve the code problem? WC-API


  • QA Engineer

    XMLHttpRequest cannot load https://api.vk.com/method/audio.get?owner_id=171166379&count=81&access_toke…09b13baa888c131fb310a1221cd086b043sa22wqd. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://w-0rld.ru' is therefore not allowed access.
    

    ♪ This is a mistake when I want audio recordings.

    getJSON('https://api.vk.com/method/audio.get?owner_id='+id+'&count=81&access_token=' + token, function(t) { ... ...As I realized, Vc doesn't get a list, there's a ban. Is there another way to get the data?



  • You should have added the argument: crossDomain.

    $.ajax({
        url: 'https://api.vk.com/method/audio.get?owner_id='+id+'&count='+feo+'&access_token=' + token,
        type: 'GET',
        dataType: 'jsonp',
        crossDomain: true,
        success: function(data){
        var e = data.response;
        $("#box").html(TPL_find);
        for (var n in e) {
                    songs.push(data.response[n].url);
                    titles.push(data.response[n].artist + " - " + data.response[n].title);
                    $("#box").append('<div class="t" id="t' + n + '" title="' + data.response[n].artist + ' - ' + data.response[n].title + '"><a href="#" onclick="play(' + n + ');return false;">' + data.response[n].artist + ' - ' + data.response[n].title + '</a><a href="' + data.response[n].url + '" target="_blank" style="float:right;">&darr;</a></div>');
        }
        $("#box").append(TPL_end);
        $("#t0").attr("style","display:none;");
        }
    });
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2