Gives an error in the console No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'file://' is therefore not allowed access.

Request itself

 $("#id_button").click(function (e) { e.preventDefault(); var UserId = $('input[name=SteamId]').val().trim(); if (!UserId) { alert("Вы забыли указать имя"); return; } console.log("id_button"); $.ajax({ method: "GET", url: "...users/add/?usersid=" + UserId, dataType: "json", success: function (data) { console.log(data.steamid); $("#steam-id-result").text(data.steamid); } }) }); 
  • Are you making a request to another domain? - Klimenkomud
  • @entithat I think the author just cut off a piece of the domain. Or does not know what to write in the url - Klimenkomud
  • Yes, my project is on codeanywhere.com - MegaRoks
  • And access to the code from which the answer should come - is there? - Klimenkomud
  • in url is a link to add to the database - MegaRoks

1 answer 1

If you have access to the server code for which you are making a request, add the following line to the response header:

 Access-Control-Allow-Origin: * 

In the case of php it will be something like this:

 header('Access-Control-Allow-Origin: *'); 

Instead of the * sign, you can enter your domain from which you make a request.
If you can not edit the server code - you will not be able to send a request to the domain, which returns the answer without this header.