表单代码
ajax代码:
python代码
@web.route('/tpush/pl',methods=['POST'])
def web_tpush():
cname = request.form['cname']
cemail = request.form['email']
curl = request.form['curl']
#ctext = request.form['ctext']
print(cname,cemail,curl)
error = None
if len(cname) < 2:
error = '666'
if len(cemail) < 5:
error = '777'
if error is not None:
return jsonify({'r':1,'error':error})
return jsonify({'r':0,'rs':ok})
我点击提交后跳转到/tpush/pl
提示:
4000 Bad Request
The browser (or proxy) sent a request that this server could not understand.
127.0.0.1 - - [13/May/2017 19:57:42] "POST /tpush/pl HTTP/1.1" 400 -
127.0.0.1 - - [13/May/2017 19:57:42] "POST /tpush/pl HTTP/1.1" 400 -
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
改为
另外,你的form里有默认post 提交。如果想要自己处理的话,就不要在form里外加action 了。