Goodnight.

I send ajax request to the script, and the script has a redirect to the site (say example.com). So, how to catch where the script wants to redirect you, and not get an error like XMLHttpRequest cannot load http://telegram.com . No 'Access-Control-Allow-Origin' header is present. Origin ' http://example.com ' is not allowed access.

  • From the browser - in any way, only to redo the server, so that instead of the redirect I would give just a link - andreymal
  • @andreymal But doesn’t the status answer come in and the address is redirected to where? like $.post('/redirected', {}, function(response, status, request) { if (status == STATUS.REDIRECT) { console.log(response.redirectUrl); } }); - Alexey Shimansky
  • all the same error displays. I just need a redirect :( - ikerya
  • @ikerya and in a try / catch wrap?) - Alexey Shimansky
  • @ Alexey Shimansky for example? - ikerya

1 answer 1

In order not to get the error "No 'Access-Control-Allow-Origin'", the server should give this header.

And get - a link to the redirect - programmatically. Or you do not have access to the server?

  • I send a request from the site console to the same site. But there is no access to this site. - ikerya
  • header ('Access-Control-Allow-Origin: *'); Give this header on the server side, and there will be no error - user190134