Revision 874cdb18
Von Jan Büren vor mehr als 3 Jahren hinzugefügt
SL/ClientJS.pm | ||
---|---|---|
303 | 303 |
// In the client generate an AJAX request whose 'success' handler |
304 | 304 |
// calls "eval_json_result(data)": |
305 | 305 |
var data = { |
306 |
action: "SomeController/the_action",
|
|
306 |
action: "SomeController/my_personal_action",
|
|
307 | 307 |
id: $('#some_input_field').val() |
308 | 308 |
}; |
309 | 309 |
$.post("controller.pl", data, eval_json_result); |
310 | 310 |
|
311 |
Now some Perl code:
|
|
311 |
Now some Controller (perl) code for my personal action:
|
|
312 | 312 |
|
313 |
# In the controller itself. First, make sure that the "client_js.js" |
|
314 |
# is loaded. This must be done when the whole side is loaded, so |
|
315 |
# it's not in the action called by the AJAX request shown above. |
|
316 |
$::request->layout->use_javascript('client_js.js'); |
|
317 |
|
|
318 |
# Now in that action called via AJAX: |
|
319 |
sub action_the_action { |
|
313 |
# my personal action |
|
314 |
sub action_my_personal_action { |
|
320 | 315 |
my ($self) = @_; |
321 | 316 |
|
322 | 317 |
# Create a new client-side JS object and do stuff with it! |
Auch abrufbar als: Unified diff
POD für ClientJs aktualisiert