Is there a XDomainRequest equivalent in Firefox?
Asked Answered
G

2

12

Is there an equivalent to Internet Explorer's XDomainRequest in Firefox or any of the other browsers?

I'd like to access a service/website outside of my domain.

Giaour answered 24/4, 2009 at 18:37 Comment(3)
This looks pretty much like a duplicate of #668019 but I don't know how XDomainRequest well enough to say if it's an exact duplicate.Stipulate
Hmm this seems relavent...machineware.com/blog/…, but it's only in IE8 and FF3.1 Seems to me there's another way or two that you should be able to do this...Giaour
(So that we don't have to require the user to be using IE8 or FF3.1)Giaour
A
21

The XDomainRequest object in Internet Explorer 8 is a proprietary method for requesting resources which are outside the "same-origin policy."

Firefox 3.5+ and Safari 4+ allow cross-domain requests through the XMLHTTPRequest object. User agents that support XMLHTTPRequest Level 2 must have Cross-Origin Resource Sharing support (CORS), which allows retrieving the resource IF the resource announces that it can be requested from other domains.

Keep in mind that the resource must declare itself as a cross-origin resource before a compliant user agent will retrieve the resource.

More info here: http://www.w3.org/TR/cors/ and at /TR/XMLHttpRequest2 on the W3C website.

Allcot answered 28/9, 2009 at 21:9 Comment(0)
B
2

It's possible, you just have to set Cross-Domain headers at the target server.

.htaccess example:

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "X-Requested-With"
Header set Access-Control-Max-Age "60"

XmlHttpRequest will submit an OPTIONS request to the target server which will respond with those headers, allowing the client to submit the intended request.

Source: http://www.oriontransfer.co.nz/blog/2011-05/cross-domain-ajax/index

Brehm answered 10/5, 2011 at 15:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.