I am trying to make ajax calls using jsRoutes in a gaming infrastructure. It works great for queries that take no parameters, but when I try to call a controller method that takes Long as a parameter, it fails without an error message. Here is some code to better explain.
Users.java controller class:
public static Result addToShortList(long id) { return whatever }
Conf / Routes
POST /shortList/:userId controllers.Users.addToShortList(userId: Long)
In the Application.java controller file, I return jsRoutes as follows:
public static Result javascriptRoutes() { response().setContentType("text/javascript"); return ok(Routes.javascriptRouter("jsRoutes", controllers.routes.javascript.Application.frontpage(), ... controllers.routes.javascript.Users.addToShortList(), controllers.routes.javascript.Users.removeFromShortList())); }
Now in my javascript I can use jsRoutes by doing the following:
jsRoutes.controllers.Users.addToShortList(id).ajax({ success : function(data) { alert(data); }, error : function(err) {
It seems that this functionality of the playback platform is poorly documented, or maybe I'm just blind to find nothing ...
Thanks for any help!
Runar false
source share