Thursday, November 24, 2011

Cross Domain Access Policy solution using Cross Origin Resource sharing

while making an HTML5 mobile app major problem we face is while integrating it with web services, the reason being Cross Domain access (as our services are on a different domain). The solution to this is given by HTML5 CORS here is the link http://www.w3.org/TR/cors/ its w3c Specification. I am using jquery.ajax to call my web services and parse the response and populate the UI. To implement CORS in jquery i found this jquery plugin useful. https://github.com/coolaj86/jquery-cors One more change that we will have to do is on the server where our service is hosted. We would have to add following in response headers Access-Control-Allow-Origin : * Access-Control-Allow-Method : GET, POST, OPTIONS and there you go you have a mobile application that is now capable of making cross domain access. Refrences http://saltybeagle.com/2009/09/cross-origin-resource-sharing-demo/ Demo Link : http://saltybeagle.com/cors/

2 comments:

  1. Hello,
    The Article on Cross Domain Access Policy solution using Cross Origin Resource sharing is Awesome.It give detail information about it .Thanks For Sharing the information about it. Xamarin Developer

    ReplyDelete
  2. I was reading your web designing post. It was amazing and nice information Great lists that really presents at lot of interesting examples.
    Web development Company in India Company | Web development Company Bangalore
    Web Development Company in Bangalore | Responsive Web development

    ReplyDelete