Reputation: 1707
i tried like this :
<head>
<meta http-equiv="Access-Control-Allow-Origin" content="http://localhost" />
<script src="jquery.js" type="text/javascript" ></script>
</head>
i tried putting * also, i tried running directly by opening an html file on the computer and also i tried using http://localhost/filename.php , tried /filename.html , but didnt work .
Tried below php code also(i put that above html tag) :
<?php
header('Access-Control-Allow-Origin : *');
?>
<html>
<head>
But getting error : Origin http://localhost is not allowed by Access-Control-Allow-Origin.
If i run directly from file, getting error : Origin null is not allowed by Access-Control-Allow-Origin.
Whats the solution ?
Thanks
Upvotes: 2
Views: 1736
Reputation: 1450
This is a server setting (as far as I understand it). You can put this in an Apache (if you're running Apache) config file in the
<Directory>, <Location>, <Files> or <VirtualHost>
sections, or within an .htaccess file:
Header set Access-Control-Allow-Origin *
Also, * could be "http://localhost". Make sure mod_headers is enabled/installed.
Upvotes: 1