实际上我试图从我的.py脚本中得到一些回复,而不是响应我获取整个文件 这是javascript文件中的ajax调用
$.ajax({
url: "py/simple.py",
type: "POST",
data: {foo: 'bar', bar: 'foo'},
success: function(response){
log(response);
$("#div").html(response);
}
});
这是py脚本
import cgi, cgitb
cgitb.enable() # for troubleshooting
#the cgi library gets vars from html
data = cgi.FieldStorage()
#this is the actual output
print "Content-Type: text/plain\n"
print "The foo data is: " + data["foo"].value
print "<br />"
print "The bar data is: " + data["bar"].value
print "<br />"
print data
我得到的回应是整个
import cgi, cgitb
cgitb.enable() # for troubleshooting
#the cgi library gets vars from html
data = cgi.FieldStorage()
#this is the actual output
print "Content-Type: text/plain\n"
print "The foo data is: " + data["foo"].value
print "<br />"
print "The bar data is: " + data["bar"].value
print "<br />"
print data
任何帮助??
答案 0 :(得分:0)
您的网络服务器配置错误。您需要告诉它您的请求是执行cgi-bin(而不是回送文件内容)。类似的东西:
ScriptAlias /cgi-bin/ "/path/to/cgi-bin/folder"