при попытке напечатать переменную, переданную как x
, которая содержит элементы из текстового поля, в мой скрипт на python через ajax, он выдает сообщение об ошибке TypeError: not indexable
Я попытался сохранить значение FieldStorage в другой переменной, чем при печати:
post = cgi.FieldStorage()
thing = post.getvalue("x")
print thing
но он все равно подсказывает мне ту же ошибку
вот мой код ajax:
$.ajax({
type: 'POST',
url: 'test.py',
cache: false,
contentType:"application/text-plain; charset=utf-8",
data: {
"x": $("input#name").val()
},
success: function(data) {
$("p#second").text(data);
},
error: function(data){
$("p#second").text("ya sorry nah");
}
});
точная ошибка:
Traceback (most recent call last): File "/home/main/code/test.py", line 12, in <module> thing = post.getvalue("x") File "/usr/lib/python2.7/cgi.py", line 548, in getvalue if key in self: File "/usr/lib/python2.7/cgi.py", line 594, in __contains__ raise TypeError, "not indexable" TypeError: not indexable -->