Den här webbplatsen har begränsad funktionalitet medan vi utför underhåll för att förbättra din upplevelse. Om en artikel inte löser ditt problem och du vill ställa en fråga har vi vår gemenskap som väntar på att hjälpa dig på @FirefoxSupport på Twitter, /r/firefox på Reddit.

Sök i support

Akta dig för supportbedrägerier: Vi kommer aldrig att be dig att ringa eller skicka ett sms till ett telefonnummer eller dela personlig information. Rapportera misstänkt aktivitet med alternativet "Rapportera missbruk".

Läs mer

firefox blocks ajax http request

  • 4 svar
  • 2 har detta problem
  • 31 visningar
  • Senaste svar av 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.

Alla svar (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?

Ändrad av petr.sponky

more options

Delete this item.

Ändrad av petr.sponky

more options

Is there anybody to help me?

more options

Nice community support. Thanks.