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 error comes out when I want to get audio recordings. getJSON('https://api.vk.com/method/audio.get?owner_id='+id+'&count=81&access_token=' + token, function(t) { ... ... As I understand it, not gives a list - it is worth some kind of prohibition. Is there another way to get data?

  • When access_token you get access_token did you request the scope rights to audio audio ? if not, then it would be necessary - Alexey Shimansky

1 answer 1

We had to add an 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;"); } });