I make such an AJAX request using jQuery

$.ajax({ url: 'https://services.sferainfo.net/api_school/?geo_school', type: 'GET', dataType: 'json', crossDomain: true, success: function(data){ console.log("ok"); }, error: function () { console.log("error"); } }); 

There is such a mistake

map.html: 1 XMLHttpRequest cannot load https: //. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://newglk.dev:8088 ' is therefore not allowed access.

  • one
    In your case - no way. In order for the cross-site request to work, you need to change the configuration on the services.sferainfo.net server - if you do not have access to this server, then read about JSONP . - Aleks G
  • 2
    JSONP is also not an option if the target server's API does not support this method. - Dmitriy Simushev
  • Here you have a problem related to the fact that you can send a request only to the server from which the document was received (the page from which the request is sent), this is called a policy of common origin. You can bypass it through JSONP - that is, it is like loading the scripts, or the server should give the appropriate header. - RussCoder
  • php curl - the solution to your problem. - Jean-Claude

0