我只是想序列化提交的表单的各个领域,像这样在PHP:序列化表单提交值
json_encode($_GET)
json.dumps(self.request.get)
不起作用:
<type 'exceptions.TypeError'>: <bound method Request.get of <Request at 77ea190 GET http://localhost:8083/?a=value>> is not JSON serializable
args = ('<bound method Request.get of <Request at 77ea190...ocalhost:8083/?a=value>> is not JSON serializable',)
message = '<bound method Request.get of <Request at 77ea190...ocalhost:8083/?a=value>> is not JSON serializable'
我我尝试过使用CGI模块,这也给了一个不可序列化的错误。我想知道的情况是:我使用它将数据发送回我的模板以重新填充表单域。
对于URLEncode这些参数比对JSON进行编码更有意义 - 在这种情况下,您可以使用'self.request.query'以原始形式获取它们。 – 2012-01-09 05:41:50
@NickJohnson 我会这样做,如果我不使用称为填充的jQuery插件。它照顾我的每一件事;它只是想要一个表单内容的JSON字符串。这非常方便:http://tinyurl.com/lmblvv – ofko 2012-01-09 06:45:30