2

I am trying to send a post Request from www.websiteA.com to www.websiteB.com. I am sending the POST from Javascript with XMLHttpRequest on A to a python script on B. The python file on B, is called my_save.py and is located at /var/www/cgi-bin/my_save.pyand so in the directory /var/www/ I added a .htaccess file that contained this

<IfModule mod_headers.c>
  Header set Access-Control-Allow-Origin "*"
</IfModule>

As I saw on this question htaccess Access-Control-Allow-Origin and other places telling me to do this.

But the same error

XMLHttpRequest cannot load http://websiteB.com/cgi-bin/my_save.py. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://websiteA.com' is therefore not allowed access.

How can get rid of this error and make the post to websiteB?

Thanks for the help

Community
  • 1
  • 1
spen123
  • 3,464
  • 11
  • 39
  • 52
  • have you read [CORS documentation on MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) - not the definitive CORS docs, but I find them readable – Jaromanda X Nov 30 '15 at 10:37
  • Are you sure `mod_headers` is enabled? Remove the condition statement `` and just leave `Header set Access-Control-Allow-Origin "*"` If you get a server error it's probably not enabled otherwise it is enabled if you don't get an error. – Panama Jack Nov 30 '15 at 11:42

1 Answers1

1

You may instead just add this to the top of your python file:

print "Access-Control-Allow-Origin: *"

Source: Here

adit-39
  • 79
  • 6