Is there a XDomainRequest equivalent in Firefox?

前端 未结 2 652
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 18:39

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.

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 18:59

    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

提交回复
热议问题