jquery - Why can't I return a json object from a Perl script? -


i doing little project uses jquery,ajax,json,and perl. on backend, using perl , cgi module return json ojbect.

#!/usr/software/bin/perl5.8.8  use strict; use warnings; use cgi qw(:standard); use json;  print header('application/json'); $json; # json returned based on params, # using list example. $json->{"entries"} = [qw(green blue yellow red pink)]; $json_text = to_json($json); print $json_text; 

i able write above script, of how can send json response perl cgi program?

this script called using jquery's get:

jquery.getjson("script.pl?something=whatever", function(data, status) {     console.log(data);     console.log(status); },"json").error(function(jqxhr, textstatus, error) {     /* ending here. */     console.log(jqxhr);     console.log("error: " + textstatus + ", " + error); }); 

from above jquery call, expecting json object back, instead entire perl script. know content type set correctly, because when execute script command line:

content-type: application/json 

can please me figure out. thank you.

instead entire perl script

the server isn't running perl script, serving plain text.

you need read manual server find out how configure cgi.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -