好的,让我们转到您的更新问题。
首先,您应该以字符串表示形式传递Ajax数据属性。然后,因为你混合
dataType和
contentType性质,变化
dataType值
"json":
$.ajax({ url: "saveList.py", type: "post", data: JSON.stringify({'param':{"hello":"world"}}), dataType: "json", success: function(response) { alert(response); }});最后,如下修改您的代码以使用JSON请求:
#!/usr/bin/pythonimport sys, jsonresult = {'success':'true','message':'The Command Completed Successfully'};myjson = json.load(sys.stdin)# Do something with 'myjson' objectprint 'Content-Type: application/jsonnn'print json.dumps(result) # or "json.dump(result, sys.stdout)"结果,在
successAjax请求的处理程序中,您将收到带有
success和
message属性的对象。



