I am using Play Framework and Angularjs for my application. My requirement is to redirect Play framework page based on some parameter selected on UI.
Here is my code,
On Page I opened bootstrap modal dialog and on submit action calling angular post method,
$scope.loginToExt = function() {
var data = $scope.env;
$http.post('/login', {env: data})
.success(function(data){
//$scope.env = data
})
.error(function(data){
console.log(data)
});
};
Once I click submit on my modal it will call '/login' and based on my route mapping will call action method as below,
def login = Action(parse.json) { implicit request =>
val env = (request.body \ "env").as[String]
env match {
case _ => {
Redirect("https://google.com")
.withHeaders(ACCESS_CONTROL_ALLOW_ORIGIN -> "*")
}
}
Route file as below,
POST /login controllers.Application.login
I don't know what the issue is but I was getting error as below and unable to redirect my page.
XMLHttpRequest cannot load https://google.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.