How to enable CORS on Firefox?

后端 未结 6 688
我在风中等你
我在风中等你 2020-12-03 04:49

Can somebody please tell me how I allow CORS on firefox? I easily managed it on Chrome and IE, but I am totally failing at it with Firefox. I edited the following about:conf

6条回答
  •  猫巷女王i
    2020-12-03 04:59

    Very often you have no option to setup the sending server so what I did I changed the XMLHttpRequest.open call in my javascript to a local get-file.php file where I have the following code in it:

    javascript is doing this:

    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
        // File content is now in the this.responseText
      }
    };
    xhttp.open("GET", "get-file.php?url=http://site/file", true);
    xhttp.send();

    In my case this solved the restriction/situation just perfectly. No need to hack Firefox or servers. Just load your javascript/html file with that small php file into the server and you're done.

提交回复
热议问题