3

I'm just making an ajax post request and I'm getting an error like:

XMLHttpRequest cannot load https://xxx.com?redirect_uri=http://www.example.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://example.com' is therefore not allowed access.

And here I can see there is nothing different from my response domain and request domain except "www", so does "www" also cause this issue?

Generic Bot
  • 309
  • 1
  • 4
  • 8
harishkumar329
  • 1,210
  • 4
  • 16
  • 34
  • possible duplicate of [jQuery xml error ' No 'Access-Control-Allow-Origin' header is present on the requested resource.'](http://stackoverflow.com/questions/19821753/jquery-xml-error-no-access-control-allow-origin-header-is-present-on-the-req) – Amir Ali Akbari Dec 02 '13 at 04:06

2 Answers2

4

The problem is because you are making a cross-domain AJAX request, which prevented by browser security - see the Same Origin Policy.

The request is expecting you to be making a request to a CORS enabled domain, hence why it is complaining about the non-existant header.

You either need to change your request to jsonp type, or use a server-side proxy to get the data.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
1

When requesting data from external website it is always best to not do it in ajax , but if you have to do it an ajax have a internal page which makes a call with server side code and call that page with ajax.