Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

firefox blocks ajax http request

  • 4 回覆
  • 2 有這個問題
  • 31 次檢視
  • 最近回覆由 petr.sponky

more options

Hello, I have problem with Firefox when web application goes on https and there is ajax request to http. Firefox say: Cross-Origin Request Blocked: The Same Origin policy disallows reading the remote resource at http://localhost/... (Reason: CORS request did not succed). Problem is firefox doesn't send OPTION request to web api. So server part is not in game. When I change address to web api to https, firefox sends OPTION request. IE, Edge, Chrome, Opera works fine. Problem is firefox only. Why? How can I change settings to send ajax request to http when web application is on https? I cannot change web api to https! I try send request through XMLHttpRequest in javascript. I tried to set up security.fileuri.strict_origin_policy to false but nothing change. I tried to add <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> tag into page but nothing change. When I downgrade application to http it works fine. So I think there should not be problem on server side. There are following headers on server side: "Access-Control-Allow-Origin", "*" "Access-Control-Allow-Methods", "POST, OPTIONS, GET" "Access-Control-Allow-Headers", "Content-Type, Accept, Authorization, x-requested-with"


There is function which is in web application: function SendData(url, data, handler) {

       var invocation = new XMLHttpRequest();
       invocation.open("POST", url, true);
       invocation.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
       invocation.onreadystatechange = function () {
           if (this.readyState == 4 && this.status == 200)
               handler(invocation.responseText, this.status);
       }
       invocation.send(data);
   }

I need help to solve this problem to send ajax request from https web application into http web api. Thank you.

Hello, I have problem with Firefox when web application goes on https and there is ajax request to http. Firefox say: Cross-Origin Request Blocked: The Same Origin policy disallows reading the remote resource at http://localhost/... (Reason: CORS request did not succed). Problem is firefox doesn't send OPTION request to web api. So server part is not in game. When I change address to web api to https, firefox sends OPTION request. IE, Edge, Chrome, Opera works fine. Problem is firefox only. Why? How can I change settings to send ajax request to http when web application is on https? I cannot change web api to https! I try send request through XMLHttpRequest in javascript. I tried to set up security.fileuri.strict_origin_policy to false but nothing change. I tried to add <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> tag into page but nothing change. When I downgrade application to http it works fine. So I think there should not be problem on server side. There are following headers on server side: "Access-Control-Allow-Origin", "*" "Access-Control-Allow-Methods", "POST, OPTIONS, GET" "Access-Control-Allow-Headers", "Content-Type, Accept, Authorization, x-requested-with" There is function which is in web application: function SendData(url, data, handler) { var invocation = new XMLHttpRequest(); invocation.open("POST", url, true); invocation.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); invocation.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) handler(invocation.responseText, this.status); } invocation.send(data); } I need help to solve this problem to send ajax request from https web application into http web api. Thank you.

所有回覆 (4)

more options

I added image where you can see OPTION request is not send when I call http page on localhost but it is send when I call https page on localhost. I need to solve this issue to send option request on http page on localhost when web application is on https. How to do it?

由 petr.sponky 於 修改

more options

Delete this item.

由 petr.sponky 於 修改

more options

Is there anybody to help me?

more options

Nice community support. Thanks.