Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4077408
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:32:47+00:00 2026-05-20T17:32:47+00:00

I wonder how can I make a cross domain request from a gwt application

  • 0

I wonder how can I make a cross domain request from a gwt application to a grails action. I know there is a wgt-plugin for grails but the development with this plugin is so slow (because I have to compile after each changes in the gwt-code). So I try to develop the gwt part separately and get the data from the grais application via ajax request. But the gwt application is running on a different server (gwt:port 8888, garils:port 8080). If I try to request the grails action I get this error in the browser:

XMLHttpRequest cannot load http://localhost:8080/MyApp/MyDomain/myAction. 
Origin http://127.0.0.1:8888 is not allowed by Access-Control-Allow-Origin.

I try to modify the response header in the grails action:

response.setHeader('Access-Control-Allow-Origin', "http://127.0.0.1:8888");

And if I call the action from a browser in the header I can find:

Access-Control-Allow-Origin:http://127.0.0.1:8888

But is do not solve the problem. What I do wrong?

Thanks in advance,

Medrod

UPDATE:

The solution is JSONP.
On the GWT-Site my code looks like this:

private void jsonp() {

JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
String URL = "http://localhost:8080/MyApp/myDomain/myAction";

jsonp.requestObject(URL, new AsyncCallback<JavaScriptObject>() {
    @Override
    public void onFailure(Throwable caught) {

    }
    @Override
    public void onSuccess(JavaScriptObject result) {

    }
});

}

And the grails code look like this:

def myAction = {
    def results = MyDomain.findAll()
    render "${params.callback}(${results as JSON})"
}

Thanks to Mic.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:32:48+00:00Added an answer on May 20, 2026 at 5:32 pm

    Web browsers have a built in security mechanism called Same Origin Policy (SOP) that prevent you to do that.

    You can use JSONP, which is embedding you response in a Javascript function that will be called when the file is loaded and injected in your page as a SCRIPT tag.

    For instance a response could be something like:

    myCallbackFunction('a string parameter', {or:{a:json:'data'}}, ...)
    

    And in your page you have a function:

    myCallbackFunction(str, json, ...){...}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can only think of Peek() and ReadNoAdvance() atm, but I wonder if there
i wonder how you can make an advanced Android User interface where you can
I wonder how I can make PHPDoc-comments visible in Eclipse on a project-wide basis.
I am new to Haskell and I wonder how/if I can make this code
I am going to develop ICQ client and I just wonder where can I
I wonder if They can work perfectly together...
I wonder if anyone can provide me with the regular expressions needed to parse
I wonder if I can test landscape view using simulator?
I always wonder why compilers can't figure out simple things that are obvious to
I am using a DBGrid component in Delphi. I wonder how I can set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.