I'm new to play and try some simple things with AJAX. Right now I just want to send some data to some controllers and send some back. I do not know how I can feel it in play.
I
$ (Url, {data: 'input'), work () {make something}); out.println ("html output") > If I want to print something in my html file I hope you will get this point
In Play, there is a function in my controller (this is nonsense, just a test ...)
public static zero doIt (string input) {string out = input + "_foo"; Render (outside); } I try to call this function with JQuery / AJAX like this:
$ (document) .ready (function ( ) {// When I click a button ... $ ("Send"). Click (function () {var url = # {jsAction @doIt (': input') /} $ .get (url ( {Input: 'x'}), function () {...});});}); It is taken from this tutorial and does not work Do anyone give me an idea that the controller and JS have to send some random strokes to their controller and how to write something back .
Cheers
instead of the render text < Code> render () : try public static zero DoIt (string input) {string out = input + "_foo"; RenderText (outside); } And try to clearly define your controller if your view (where you write scripts) is not your controller:
$ (Document)) .ready (function () {// When I click a button ... $ ("# send"). Click (function () {var url = # {jsAction @ YourController.doIt ( ': Input') /} $ .get (url ({input: 'x'}), function () {...});}); });
This works for me. And important thing: it will not work in the visible file only, separate JS
Comments
Post a Comment