PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : CORB block using API via JQuery



mR12
22.07.2018, 18:05
Hello,

I cannot access the API via JQuery. I am getting this error:


Failed to load https://filecrypt.cc/api.php?api_key={my_api_key)&fn=containerV2&sub=listV2&state=offline: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.

VM598:1 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://filecrypt.cc/api.php?api_key={my_api_key}&fn=containerV2&sub=listV2&state=offline with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

Is it not possible to use JQuery to access the API? Here's my simple code:


$.getJSON('https://filecrypt.cc/api.php?api_key={my_api_key}&fn=containerV2&sub=listV2&state=offline',function(data) {
console.log(data);

});

Thanks,
mR12

EVXN
22.07.2018, 19:20
Starting from the fact that the request should be a POST request...
Such a request will only be possible via a proxy on your server (accessible from the internet) - a cross-link information retrieval is blocked by all common browsers to protect data.

darkness
22.07.2018, 19:30
You can try jsonp https://learn.jquery.com/ajax/working-with-jsonp/

GipsyDanger
23.07.2018, 07:04
Hello,

it's deactivated with purpose, please create a local PHP file on your server which bridges the request, this will also secure your API-KEY.