Wednesday, 4 November 2015

How to send jQuery POST request on cross-domain

For the specific domain see below:
// Allow from any origin
if (isset($_SERVER['HTTP_ORIGIN'])) {
   header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); 
   header('Access-Control-Allow-Credentials: true');
   header('Access-Control-Max-Age: 86400');    // cache for 1 day
If you want to allow from any domain see below:

Header set Access-Control-Allow-Origin *
Header set Access-Control-Allow-Headers "content-type"

1 comment: