I am newbie in python and am using Python to get the request from AJAX calls but I am getting the code of python as it is inside the AJAX output which I don't want.
AJAX Code :
$.ajax({
type: "POST",
url: "hello.py",
datatype : "json",
data: { name: "nitin"}
})
.done(function(msg) {
console.log(msg);
$("div").html("Data : "+msg)
});
Python Code :
import sys
import cgi
sys.stdout.write("Content-Type: application/json")
sys.stdout.write("
")
sys.stdout.write("
")
form = cgi.FieldStorage()
sys.stdout.write(json.dumps({ 'data': form.getvalue('name')}))
Output : Data : import sys import cgi sys.stdout.write("Content-Type: application/json") sys.stdout.write("
") sys.stdout.write("
") form = cgi.FieldStorage() sys.stdout.write(json.dumps({ 'data': form.getvalue('name')}))
Expected Output should be :
Data : Content-Type: application/json
nitin