0
votes

I started to work on the Website for our FiveM Server today and want to get the data of a .json file, which is located on our server, from our server. The problem is, that i can't get get access to the local file from our localhost... Im working on this since hours and can't find a solution for this problem.

Console Error:

Access to XMLHttpRequest at 'http://45.91.251.46:30120/dynamic.json' from origin 'http://45.91.251.46' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Javascript / JQuery

$(function() {

  $(document).ready(function () {
    $.ajax({
      type : "GET",
      url: "http://45.91.251.46:30120/dynamic.json",
      dataType: "json",
      success: function (data) {
        console.log(data[0].clients + " " + data[0].sv_maxclients);
      }
    });
  });

});

I would appreciate any type of help <3

You're violating the same-origin policy because the port number in the AJAX call is different from the port in the original page. - Barmar