use strict;
use warnings;
use CGI;
use HTTP::Daemon;
use HTTP::Status;
use URI::Escape;
use JSON;
use Encode qw/decode_utf8/;
my $query;
my @countries = <DATA>;
chomp foreach @countries;
my $port =
code => $c, } } @countries_list;
my $json = to_json(\@choices, {ascii => 1});
print STDERR "RESPONSE: $json\n";
my $response = HTTP::Response->new(RC_OK);
'Pragma' => 'no-cache',
'Expires' => '0');
$response->content($json);
$client_connection->send_response($response);
}
elsif ($path_info =~ s[^g/country
l_display_here',
toolbar_container: 'grid_toolbar_will_display_here',
dto: {VUE: 'JSON'},
columns: [
{label: 'Full Name', value: function(e) {
retu
ESCRIPTION
Displays a dataset in a grid format.
Dataset is bound to a JSON datasource retrieved via an AJAX request.
JSON object has a predefined format that the Grid class understands and rende
ast page correspondingly.
=back
=head1 JSON Datasource
As mentioned before, the Grid expects the JSON datasource object to be of a predefined format.
json = {
'liste' : [
{'fname':
then an Ajax request
will be sent to C</myapp/completion?search=ab>.
The server should return a JSON array, in the format explained below.
=item a callback function
That function will be called, w
See also C<options.caseSensitive>.
=item an object (JSONP)
Useful when accessing data on a different domain via JSONP services.
Ex : { json_url: 'http://search.yahooapis.com/WebSearchService/V
&query=?1&output=json&callback=?2',
json_list: 'ResultSet/Result' }
The object should hold details of the JSONP service to be called.
C<json_url> : url to call with placeholders (?1, ?2)
type.getJSON
Prototype.getJSON(url, callback)
based on: getJSON function by Juriy Zaytsev L<http://github.com/kangax/protolicious/tree/master/get_json.js>
A method to temporarily load JSON data (
ideally hosted on a different domain and accessible via JSONP service) and send it over to callback method when ready.
=head2 Hash utilities
=head3 Hash.expand
var tree = Hash.expand(flat_hash);