Last week, I wanted to make some Ajax requests from a page generated by some web application to another web application. These two applications are hosted in two different servers, with different domains. To do this type of a thing, you can't use a normal method because of the limitations set in place by "Same Origin Policy".
Same Origin Policy is a security concept for client side programing languages. This policy prevents the client side scripts accessing the pages from different web sites. For an example, if your application is hosted in the "hostA" and a client side script of your application wants to send an Ajax request to a another application that is hosted in "hostB", then this request will be prevented by the Same Origin Policy. To be able to make that type of a request, both host and protocol should be same, according to the Same Origin Policy.
For more details :
http://en.wikipedia.org/wiki/Same_origin_policy
https://developer.mozilla.org/En/Same_origin_policy_for_JavaScrip
There are few methods listed below to work around this limitation.
More details:
http://easyxdm.net
https://github.com/oyvindkinsey/easyXDM
Same Origin Policy is a security concept for client side programing languages. This policy prevents the client side scripts accessing the pages from different web sites. For an example, if your application is hosted in the "hostA" and a client side script of your application wants to send an Ajax request to a another application that is hosted in "hostB", then this request will be prevented by the Same Origin Policy. To be able to make that type of a request, both host and protocol should be same, according to the Same Origin Policy.
For more details :
http://en.wikipedia.org/wiki/Same_origin_policy
https://developer.mozilla.org/En/Same_origin_policy_for_JavaScrip
There are few methods listed below to work around this limitation.
- With html5 there is a method formalized for this, but it supports only in the newest browsers.
- Cross Origin Resource Sharing (CORS) : This is a way of enabling open access between cross domains by making the server to be accessed by the pages of other servers. This is an excellent guide for this method: http://enable-cors.org/
- JSONP : This provides a method for requesting data from a different server with a different domain. For more details: http://en.wikipedia.org/wiki/JSONP
More details:
http://easyxdm.net
https://github.com/oyvindkinsey/easyXDM
Comments