TypeError:不可索引

when trying to print a variables passed in as x which contains elements from a text field to my python script via ajax, it prompts me with the error TypeError: not indexable

I have tried storing the FieldStorage value in a different variable then printing :

post = cgi.FieldStorage()
thing = post.getvalue("x")
print thing

but it still prompts me with the same error

here is my ajax code:

$.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");
    }

});

exact error:

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 -->

As @DanielRoseman mentioned you do not need the contentType in your ajax code.