0

i am using a function that take a JSON file and displaying the data in file into DataTable, using AJAX dataTables.

    $('#table4').DataTable({
        retrieve: true,
        processing:true,
        ajax: {
            url: "data.json",
            dataSrc: "Inventaire",
            crossDomain: true,
            dataType:"json"
        },
        columns: [
            { data: 'categorie' },
            { data: 'produitService' }
        ],
        "pageLength": 5
    });
});

When i try to run my files, i get the error below :

Access to XMLHttpRequest at 'file:///C:/Users/tifah/Documents/Bacc.%20Informatique%20et%20Genie%20logiciel%20Ete%202022/INF3190/publichtml/HTML/data.json?=1654390615223' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

Elfi
  • 57
  • 6

0 Answers0