From 9d37bced7dd4873f32f1374d2914e27bb984c422 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 13 Jan 2014 12:20:24 -0500 Subject: view: support jsonp callback --- cgi-bin/view | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'cgi-bin') diff --git a/cgi-bin/view b/cgi-bin/view index 526d268..3994117 100755 --- a/cgi-bin/view +++ b/cgi-bin/view @@ -53,6 +53,7 @@ sub main{ $params->{$key} = $value; } + my $callback = $params->{'callback'} || undef unless(defined $params->{f}){ not_specified_error("f"); @@ -90,11 +91,23 @@ sub main{ $res = mysql_retrieve('select shaders.* from shader_ids cross join shaders on shader_ids.id = shaders.shader_id'); } default { - print $json->pretty->encode ({ ERROR => "Function parameter f improperly defined"}); + if (defined $callback) { + print $callback + "("; + print $json->pretty->encode ({ ERROR => "Function parameter f improperly defined"}); + print ")"; + } + else { + print $json->pretty->encode ({ ERROR => "Function parameter f improperly defined"}); + } exit(1); }; } - print $res; + if (defined $callback) { + print $callback + "(" + $res + ")"; + } + else { + print $res; + } } main(); exit(0); -- cgit v1.2.3-70-g09d2