I’m loading a json file relatively using dart’s html library’s HttpRequest class. In the Dart editor it’s working fine. Using the dart plugin for intelliJ with JetBrains chrome extension I receive…
XMLHttpRequest cannot load file:///C:/project/web/path/to/my/file.json. Cross origin requests are only supported for HTTP. :0
Exception: Error: NETWORK_ERR: XMLHttpRequest Exception 101
Stack Trace: #0 HttpRequest.send (file:///E:/b/build/slave/dartium-win-full-trunk/build/src/build/Release/obj/global_intermediate/webkit/bindings/dart/dart/html/HttpRequest.dart:33:3)
I’m passing a relative url, when inspecting the URL I see its:
“path/to/my/file.json”
Here’s the bare bones test.
import 'dart:html';
main(){
Loader loader = new Loader();
loader.load("someFile.json");
}
class Loader {
load(String url) {
var request = new HttpRequest();
request.open('GET', url, true);
request.send();
}
}
I am not sure why it works in one context and not another, but basically cannot just go
GETa file if you are not usinghttp. See these for details on why this is the case. I’ve never used IntelliJ, so I cannot speak to the specifics of that context, unfortunately.