无法获得发布ajax请求数据python
我有HTML格式:
我有Button,当我点击它时,我正在做ajax post请求:
$.post( "/send-form", $('#contactForm').serialize()
在chrome web inspector中,我可以看到数据发送名称= + gfdsfd&phone = 89999
这是我使用Flask,Python的后端函数:
@app.route("/send-form", methods=['POST']) def send_form(): name = phone = email = country = text = None data = request.data print request.data
它在我的控制台中打印空字符串。 可能是什么问题?
要访问Flask的表单数据,您应该使用请求对象的form属性。
name=request.form['name'] data=request.form['phone']