I have a Play! application and from the JavaScript we now have run in to the Same Origin Policy Problem.
What I want is that JavaScript ajax calls go to our own server and that this server again route the json call to the external REST API.
My JavaScript use ajax to this url:
$.getJSON("http://mydomain.com/users", function(users) {
//callback
});
How can I easly make the server route to lets say:
public void getUsers(){
// result = call www.otherdomain.org/api/users.json What to do here?
renderJson(result);
}
and the return the response?
Or can it be done dynamically somewhere by directly rerouting?
here comes an example for doing async http calls (e.g. to facebook api)
You can use the WS class to call another URL as a web service and retrieve the answer.
See an example here