How to enable cross-domain request on the server? How to enable cross-domain request on the server? json json

How to enable cross-domain request on the server?


Access-Control-Allow-Origin: http://yourdomain-you-are-connecting-from.com

on target server

in php:

 header("Access-Control-Allow-Origin: http://yourdomain-you-are-connecting-from.com");

in case you don't want to use server-scripting language: put this in (linux) console

a2enmod headers

and to your .htaccess file add ­ ­ ­ ­ ­ ­ ­

Header set Access-Control-Allow-Origin: http://yourdomain-you-are-connecting-from.com


Put this in your .htaccess and plain ajax works

<ifModule mod_headers.c>    Header set Access-Control-Allow-Origin: *</ifModule>


the solution given by genesis worked for me, however I had to omit the trailing slash on the url. ie:

header("Access-Control-Allow-Origin: http://yourdomain-you-are-connecting-from.com");