I am new to Play and will try very simple things with AJAX. Right now I want to send data to the controller and send something back. I don’t understand how to implement this in Play.
I used to send data using
$.get(url, {data:'input'), function() { do something });
to the standard servlet found in / url. In servlet I have a simple
out.println("html output")
if I want to print something in my html file. I hope you understand.
In Play, I have a function in my controller (this is nonsense, just a test ...)
public static void doIt(String input) {
String out = input+"_foo";
render(out);
}
I am trying to call this function using jQuery / AJAX as follows:
$(document).ready(function() {
$("#send").click(function(){
var url =
$.get(url({input: 'x'}), function() {
...
});
});
});
This is taken from a textbook and does not work. Can someone give me an idea on how to write a controller and JS to send some random string to my controller and return something.
Greetings
source
share