0

There are several questions regarding this topic, but I cannot seem to find one that works for me. So far I am doing this:

load() {
var url1 = "http://tourify.herokuapp.com/json/?lat=51.4346644&lng=-0.1020241&address=15%20Chestnut%20Road,%20West%20Norwood,%20London%20SE27%209EZ,%20UK";
// call the web server asynchronously
var request1 = HttpRequest.getString(url1).then(display);
}

Here is the other function:

display(String responseText) {
String jsonString = responseText;
window.alert(jsonString);
}

I get this error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.
Exception: Uncaught Error: Instance of '_XMLHttpRequestProgressEvent'

Is there an easy way to just open the connection for anywhere?

Thanks, Luca

LucaSpeedStack
  • 513
  • 2
  • 7
  • 21
  • @Quentin I am asking this for Dart specifically. – LucaSpeedStack Sep 04 '14 at 13:30
  • There's nothing Dart specific about the problem. You still end up compiling down to JS in the browser and interacting with the Same Origin Policy. – Quentin Sep 04 '14 at 13:31
  • @Quentin The only way I could see that was relevant in the linked question is using CORS but you cannot do: XMLHttpRequest in Dart – LucaSpeedStack Sep 04 '14 at 13:33
  • If you can't use XMLHttpRequest in Dart (a) why is the error message *specifically* about a header defined by the CORS specification and (b) why does the error message mention XMLHttpRequest? – Quentin Sep 04 '14 at 13:34
  • @Quentin a) CORS is the only way that I can see will fit with what I am doing. and XMLHttpRequest class doesn't exist in the dart:js library. – LucaSpeedStack Sep 04 '14 at 13:35
  • So use CORS. You're already using XMLHttpRequest, even if you have an abstraction layer around it. – Quentin Sep 04 '14 at 13:36
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/60621/discussion-between-lucaspeedstack-and-quentin). – LucaSpeedStack Sep 04 '14 at 13:36

0 Answers0