Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax cross-sub-domain requests?

Is there a way to make an Ajax request to

s3-ap-southeast-1.s3.amazonaws.com (to S3 API)

from

s3.amazonaws.com

(from where a JavaScript app that is hosted at)?

like image 324
Dema Avatar asked Nov 05 '10 14:11

Dema


People also ask

Can I send Ajax request to another domain?

Setting up a CORS policyBy default you are not allowed to make AJAX requests to another domain. Your browser applies the Same-origin policy as part of the web security model.

What is cross domain AJAX request?

CORS is a mechanism that defines a procedure in which the browser and the web server interact to determine whether to allow a web page to access a resource from different origin. Figure 2. Cross domain ajax request. When you do a cross-origin request, the browser sends Origin header with the current domain value.

Is subdomain considered cross domain?

Cross-domain tracking only applies if you have multiple domains. If you have a single domain with multiple subdomains, cross-domain tracking is not necessary!


3 Answers

You cannot do cross-domain ajax requests. That includes subdomains. However, it is possible to use JSONP.

like image 105
jwueller Avatar answered Nov 11 '22 14:11

jwueller


yes, you can cross domain ajax calls, check cross-origin resource sharing: http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing

like image 45
Ricardo Avatar answered Nov 11 '22 16:11

Ricardo


Cross domain ajax requests are forbidden by protocol. And yes, subdomains too.

Read here: http://www.ajax-cross-domain.com/ It might help;

like image 29
Silver Light Avatar answered Nov 11 '22 15:11

Silver Light