CORS与jQuery.ajax()

时间:2014-08-21 04:36:04

标签: jquery ajax firefox xmlhttprequest cors

Firefox似乎阻止了此请求,而Chrome正在处理它。我做错了什么?

http://jsfiddle.net/e8qu2g9j/1/

$.ajax({
    url: "http://maps.googleapis.com/maps/api/geocode/json",
    data: {
        bounds: "-35.2545,149.4947|-31.9955,152.5728",
        region: "au",
        components: "country:AU|administrative_area:NSW",
        address: "Central Station"
    }
});

我尝试添加:

crossDomain: true,
xhrFields: {
    mozAnon: true,
    mozSystem: true
},

但无济于事。

Firefox 31.0一直在给我:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://maps.googleapis.com/maps/api/geocode/json?bounds=-35.2545%2C149.4947%7C-31.9955%2C152.5728&region=au&components=country%3AAU%7Cadministrative_area%3ANSW&address=Central+Station. This can be fixed by moving the resource to the same domain or enabling CORS.

编辑:这对我来说在新的Firefox配置文件中运行正常,但不是我的主要版本。我可以改变什么设置?

1 个答案:

答案 0 :(得分:1)