in reply to Preferred RPC method?
With JSON, my exposed methods are easily available to other perl scripts, or more importantly, they are available to my javascript applications (AJAX isn't quite the word here as the "Asychronous" and "And XML" don't apply in many of my scripts - so all you are left with is the the J".sub json_run_step { my $self = shift; my $form = $self->form; my $type = $form->{'type'}; my $data; my $ok = eval { die "Invalid type \"$type\"\n" if $type !~ /^[a-z]\w+$/; die "Invalid method \"$type\"\n" if ! $self->can($type); $data = $self->$type($form); }; if (! $ok) { $data = { error => "$@" || "An error occurred", }; } $self->cgix->print_content_type('application/x-javascript'); print JSON::to_json($data)."\n"; return 1; }
|
---|