You do not necessarily use cgi.FieldStorage to process POST data sent on AJAX request. This is the same as receiving a regular POST request, which means that you need to receive the request body and process it.
import SimpleHTTPServer import json class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): def do_POST(self): content_length = int(self.headers.getheader('content-length')) body = self.rfile.read(content_length) try: result = json.loads(body, encoding='utf-8')
ozgur source share