ajax不在firebase生产环境中工作,但在本地主机上工作

时间:2018-01-11 11:09:03

标签: ajax firebase-hosting

ajax在firebase生产环境中不起作用,但在localhost ajax代码上工作

var settings = { "async": true, "crossDomain": true, "url": "https://some_other_domain:3000/", "method": "POST", "dataType": "json", "headers": { "Access-Control-Allow-Origin" : "*", "Access-Control-Allow-Headers" : "Origin, X-Requested-With, Content-Type, Accept", "Access-Control-Allow-Methods" : "GET,PUT,POST,DELETE", "Content-Type": "application/json", "Cache-Control": "no-cache", }, "processData": false, "crossDomain":true, "timeout": 3000, "data": JSON.stringify(emailData) } $.ajax(settings) .done(function (response) {

on firebase-托管我的请求超时(如检查器中的网络选项卡上所示,并且控制台不显示任何错误)。在localhost它工作正常。我试过Mozila Firefox和Google Chrome。

1 个答案:

答案 0 :(得分:0)

由于AJAX cross-domain policy,您无法使用AJAX调用外部域。

Here是从外部域获取数据的另一种方法。