Erreur : No 'Access-Control-Allow-Origin' header is present

SuperRobot Messages postés 30 Statut Membre -  
SuperRobot Messages postés 30 Statut Membre -
Bonjour,
J'aimerais afficher le contenu d'une page web avec jquery en javascript, mais il y a cette erreur :
Access to XMLHttpRequest at 'https://openload.co/f/5oqJRuojsPU/Betternet.VPN.4.1.0.rar/' from index.html:1 origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


Comment puis-je résoudre ceci ???
Merci d'avance.

1 réponse

  1. jordane45 Messages postés 30427 Date d'inscription   Statut Modérateur Dernière intervention   4 831
     
    0
    1. SuperRobot Messages postés 30 Statut Membre
       
      J'ai déja essayé :
      https://stackoverflow.com/questions/20035101/why-does-my-javascript-code-receive-a-no-access-control-allow-origin-header-i
      https://web.dev/cross-origin-resource-sharing/
      Mais c'est toujours la même chose.
      function createCORSRequest(method, url) {
              var xhr = new XMLHttpRequest();
              if ("withCredentials" in xhr) {
      
                  // Check if the XMLHttpRequest object has a "withCredentials" property.
                  // "withCredentials" only exists on XMLHTTPRequest2 objects.
                  xhr.open(method, url, true);
      
              } else if (typeof XDomainRequest != "undefined") {
      
                  // Otherwise, check if XDomainRequest.
                  // XDomainRequest only exists in IE, and is IE's way of making CORS requests.
                  xhr = new XDomainRequest();
                  xhr.open(method, url);
      
              } else {
      
                  // Otherwise, CORS is not supported by the browser.
                  xhr = null;
      
              }
              return xhr;
          }
      
          xhr = createCORSRequest('GET', 'https://openload.co/f/5oqJRuojsPU/Betternet.VPN.4.1.0.rar/');
      
          xhr.onload = function() {
              var responseText = xhr.responseText;
              console.log(responseText);
          };
      
          xhr.onerror = function() {
              console.log('There was an error!');
          };
      
          xhr.send();
      
      0
    2. SuperRobot Messages postés 30 Statut Membre
       
      S'il vous plaît, pouvez-vous me répondre ?......
      0