nomnom
nomnom

Reputation: 1638

GWT - why I can't get JSON via HTTP?

The URL is http://www.iwi.hs-karlsruhe.de/Intranetaccess/REST/courseofstudies/all.json

I can view the JSON file in my browser, but when I tried to get it in GWT, the result is empty. The alert in the following code is empty.

    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, jsonURL);
    rb.setCallback(new RequestCallback() {

        @Override
        public void onResponseReceived(Request request,
                Response response) {
            Window.alert(response.getText());
        }

        @Override
        public void onError(Request request, Throwable exception) {
            System.out.println("onError");
        }
    });
    rb.send();

Upvotes: 0

Views: 59

Answers (1)

Christian Kuetbach
Christian Kuetbach

Reputation: 16060

I am pretty sure it is all about the same-origin policy.

Empty response text and a HTTP-code 0.

You cannot connect to that URL unless you are:

  1. from the same origin
  2. use JSONP
  3. use CORS-Header

Upvotes: 2

Related Questions