My grails application provides a action that should supply a gwt client with json data. If I call the action from gwt I get in browser this error:
XMLHttpRequest cannot load http://localhost:8080/myApp/myDomain/myAction/123.
Origin http://127.0.0.1:8888 is not allowed 开发者_JS百科by Access-Control-Allow-Origin.
What does this error mean? And how can I solve this problem?
GWT code:
String url = "http://localhost:8080/myApp/myDomain/myAction/123"
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url);
builder.sendRequest("", new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
GWT.log("Response: "+response.getText());
}
@Override
public void onError(Request request, Throwable exception) {
GWT.log("ERROR: " + exception.getMessage());
}
});
grails code (action):
def myAction = {
def data = ...
render(contentType:"text/json"){data}
}
You are trying to perform request on different domain. According to "Access-Control-Allow-Origin" you are able to perform request only in origin domain.
精彩评论