1

I know if you make a ajax call from example.com to yahoo.com, it is a cross domain call. But I'm not sure about the followings situations.

1) One web application in IIS with domain name "www.test.com" and I also host a web service in IIS with domain name "api.test.com". Now if I make a ajax call from "www.test.com" to "api.test.com", will this be considered as a cross domain call?

2) Same as case 1 but if I host web application ("www.test.com") on a windows server and if I host host web Service ("api.test.com") in a Linux server, and now if I make a ajax call from "www.test.com" to "api.test.com", will this be considered as a cross domain call?

1 Answers1

-1

You can not do cross domain calls using javascript. This also includes calls between subdomains.

However getting a work around to make call to a subdomain easy. You need to set same document.domain in both the pages. You can read more about it here A question about cross-domain (subdomain) ajax request

Update: Forgot to mention that cross domains are independent of backend server serving your requests. So it doesn't matter if server is IIS or Linux, it is all same.

Community
  • 1
  • 1
Gaurav
  • 1,078
  • 2
  • 8
  • 18
  • Cross-domain calls using javascript are certainly possible, in all browsers to one degree or another. Read up on CORS and JSONP. – Ray Nicholus Nov 20 '13 at 15:16
  • What I meant is, by default making a call to subdomain will result into Cross-domain error. However to make cross-domain call, your server should send response as JSONP else header should contain "Access-control-allow-origin" parameter(which I forgot to mention in answer above). My bad, in future I will formulate my words in a better way. – Gaurav Nov 21 '13 at 04:14