Running CGI Python Javascript to retrieve JSON object -


i want use javascript retrieve json object python script ive tried using various methods of ajax , post cant working.

for have tried set this

my javascript portion: have tried

$.post('./cgi-bin/serverscript.py', { type: 'add'}, function(data) { console.log('posted: ' + data); });

and

$.ajax({ type:"post", url:"./cgi-bin/serverscript.py", data: {type: "add"}, success: function(o){ console.log(o); alert(o);} });

my python

import json
import cgi
import cgitb
cgitb.enable()
data = cgi.fieldstorage()

req = data.getfirst("type")
print "content-type: application/json"
print
print (json.jsonencoder().encode({"status":"ok"}))

i getting 500 (internal server error)

have tried doing just

 print (json.jsonencoder().encode({"status":"ok"})) 

instead of printing content-type , blank line?


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -