Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Trang web này sẽ có chức năng hạn chế trong khi chúng tôi trải qua bảo trì để cải thiện trải nghiệm của bạn. Nếu một bài viết không giải quyết được vấn đề của bạn và bạn muốn đặt câu hỏi, chúng tôi có cộng đồng hỗ trợ của chúng tôi đang chờ để giúp bạn tại @FirefoxSupport trên Twitter và /r/firefox trên Reddit.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

firefox blocks ajax http request

  • 4 trả lời
  • 2 gặp vấn đề này
  • 31 lượt xem
  • Trả lời mới nhất được viết bởi 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.

Tất cả các câu trả lời (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?

Được chỉnh sửa bởi petr.sponky vào

more options

Delete this item.

Được chỉnh sửa bởi petr.sponky vào

more options

Is there anybody to help me?

more options

Nice community support. Thanks.