Reputation: 1007
I am trying to make the following code work on my website (Wordpress - Plugin). But still it is giving error, what can be the reason?
<?php
header("access-control-allow-origin: *");
?>
<div id="latest-trends" style="width: 0px;"></div>
<script type="text/javascript">
$('#latest-trends').load('https://turkcealtyazi.org/index.php #nwrap');
</script>
The error is:
Access to XMLHttpRequest at 'https://turkcealtyazi.org/index.php?_=1612044908947' from origin 'https://yoursite.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Upvotes: 0
Views: 184
Reputation: 5306
You can't send request to another server with Javascript like this. Go with server side solutions.
access-control-allow-origin
header should be provided by server that you try to connect, not you.
Upvotes: 1