0

i have a content script injected in every page of the safari browser. The blow code is injected and loading the extension json file.

var url = extensionAdapter.getExtensionURL(contents/test.json);
var request = new XMLHttpRequest();
    request.open('GET', url);

    request.addEventListener("load", function (event) {
      if (event.target.status == 200) {
        resolve(JSON.parse(event.target.response));
      }
      else {
        reject("Error loading " + url + ", Error: " + event.target.statusText);
      }
    });

    request.addEventListener("error", function (event) {
        reject("Network Error while loading "+url);
    });

    request.send();

When i ru this code It gives an error "Cross origin requests are only supported for HTTP."

Able to load json in global or Background page of the extension but i need load json file in Safari extension CS.

Valeriy
  • 1,365
  • 3
  • 18
  • 45

1 Answers1

0

This is CORS error ..To access a physical file...other than firefox you need to start a server like

httpster

or use chrome with security disable or test in firefox..

here is a solution on SO you can follow

Rohit Kumar
  • 1,777
  • 2
  • 13
  • 26