I'm running an Openfire XMPP server on a virtual hosting service. When I sent an XmlHttpRequest to that server by Javascript, I got the error from Chrome's dev console:

"XMLHttpRequest cannot load http://myxmppsite.com:9090/plugins/userService/userservice?type=add&secret=3VC72j0t&username=kafka&password=drowssap&name=franz&email=franz@kafka.com. Origin http://myanothersite.com is not allowed by Access-Control-Allow-Origin."

But when I browsed to the url directly from Chrome, it worked normally.

I googled some stuffs and modified the xmpp server's cross-domain-policy to allow requests and request headers from myanothersite.com but it still didn't work.

How can I edit the Access-Control-Allow-Origin (whatever it is) so that I can allow myxmppsite.com to accept requests from myanothersite.com?

Thanks in advance.

link|improve this question
feedback

1 Answer

You have to use JSON-P or apache/nginx proxy running on the same host.

You can check this post for more details Orgin x is not allowed by Access-Control-Allow-Origin

link|improve this answer
Thanks, I tried those methods but still didn't work. I guess the problem is sth else. Anw, I figured that host wouldn't block itself, so I transfered the code from the other host to it, and it worked :) – giang271291 Feb 8 at 12:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.