How to enable or perform CORS requests (Cross Origin Resource Sharing)

CORS Request:
A CORS request is basically a request, where your JavaScript hosted on sever A is trying to make a request to server B.
Not the be confused with the band.

A CORS request can be a security concern, because if server A hosts malicious content, then server B will not want to have its content re-presented by server A (for example, if server A is hosting a phishing site).

So out of the box, most browsers and web servers will not allow a CORS request to succeed.

Here are some notes on how to get CORS working:

ideally you should enable CORS server side
http://enable-cors.org/

Alternatively, you can try to use JSONP:
http://www.jquery4u.com/json/jsonp-examples

JSONP can be a tricky to get working - some servers require your callback function to have a special name.
Otherwise, try using Opera browser - last time I used it, it seems to allow CORS requests

IE10 – very strict about CORS. Will not pass on CORS requests unless that server allows it.
Chrome 30 – not quite as strict as IE10.

Reference:

Comments