0

I wrote a little javascript web app for iOS where I use XMLHTTPRequest to retrieve data from a web service (over which I have no control). JSONP is not available. I'm not using jQuery. When I access the site via file://, it works just fine, but when I access the site via http:// on a locally hosted server, it doesn't work. Safari complains that

Origin http://mydomain is not allowed by Access-Control-Allow-Origin

I have already tried adding Access-Control-Allow-Origin: * to my headers, but it doesn't work.

What am I doing wrong?

ryyst
  • 9,563
  • 18
  • 70
  • 97

1 Answers1

0

Access-Control-Allow-Origin: * header should be added by the web service, to allow you access the url. I didnt have comment access yet, so posted it as answer

Balaji Sivanath
  • 506
  • 4
  • 14
  • I have no control over the web service, so I can't add the headers to it. (The web service is a weather API and my app is just a frontend.) – ryyst Jun 23 '13 at 15:40
  • I just said that header should be added by the web service to enable cors, you cannot use cors method unless the web service allow it. so you have to try any other methods – Balaji Sivanath Jun 23 '13 at 15:44
  • @ryyst http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy This might help you. – Balaji Sivanath Jun 23 '13 at 15:50