I’m trying to make a POST request using JavaScript routing. In the routes file:
POST /comments controllers.Clients.addComment(text: String, client: Int)
GET /assets/javascripts/routes controllers.Application.javascriptRoutes()
on page:
jsRoutes.controllers.Clients.addComment(args.text, @client.id).ajax(...);
But it creates the request
POST http://localhost:9000/comments?text=qwe&client=1 HTTP/1.1
How do I make it pass parameters in the POST body instead of a request string?
Tak a look at ajax() documentation – that is, such example:
As Play JavaScript route already defines
urland request method (type), you need only to adddata(of course you don’t need to specify them as a params in brackets)Also you can send a text only to given client (determined by the URL (it can be
POSTbutPUTlooks nicer :)):in the view:
So it will perform PUT request to
http://domain.tld/comments/123andtextwill be available in theform()as it was sent with POST: