1

ajax not working in firebase production environment but works on localhost ajax code

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-hosting my request timeout(as seen on network tab in inspector, and console doesn't show any errors). on localhost it works fine. I tried on Mozila Firefox and Google Chrome.

Pasindu Perera
  • 113
  • 1
  • 5

1 Answers1

0

You cannot call foreign domain using AJAX due to AJAX cross-domain policy.

Here is an alternative way to get data from a foreign domain.

sumedhe
  • 934
  • 1
  • 13
  • 30