A
A
alh_22016-01-19 16:34:32
PHP
alh_2, 2016-01-19 16:34:32

What is the error XMLHttpRequest cannot load https://www.site.ru/citylist.php?id=a. No 'Access-Control-Allow-Origin' header?

.htaccess has a view code that redirects everything to https://site.ru

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Then there is an AJAX request from my site https://site.ru to my site https://site.ru/citylist.php?id=a
Here is the code
$.ajax({
      url: "https://site.ru/citylist.php?id="+encodeURI('А'),
      headers: { 'Access-Control-Allow-Origin': '*' },
      crossDomain: true,
      type: 'GET',
      success: function(result){
        	$("#vstavka").html(result);
      }
    });

For some reason, it writes an error XMLHttpRequest cannot load https://www.site.ru/citylist.php?id=A . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' https://genius.bz ' is therefore not allowed access.

My site, everything should seem to plow on http works on https nifiga.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
ozzzi, 2016-01-19
@ozzzi

Why add the 'Access-Control-Allow-Origin' header to the AJAX request if this header should be returned by the server in case of cross-domain requests?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question