html - flask button 后台form表单接收 求助

查看:262
本文介绍了html - flask button 后台form表单接收 求助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

<td>
    <button class="edit" >开</button>
</td>

在HTML的页面写的是button,在js里面写了个开关自动切换,然后ajax把信息传递到后端去

$(function () {
    $('.edit').click(function () {
        var td = $(this);
        var id = $(td).parent().parent().children('td').html();
        var business = $(td).parent().parent().children('.business').html();
        var html_edit = $(td).parent().children('.edit').html();

        if (html_edit == '开'){
            td.html('关');
             $.ajax({
             type: "post",
             url: "notice_change",
             data: { goods_id:id, business:business, notice:'关', csrf_token:$('#csrf_token').val()},
             dataType: "application/x-www-form-urlencoded",
             success: function(data){}
            });
        }
        else if (html_edit == '关'){
            td.html("开");
             $.ajax({
             type: "post",
             url: "notice_change",
             data: { goods_id:id, business:business, notice:'开', csrf_token:$('#csrf_token').val()},
             dataType: "application/x-www-form-urlencoded",
             success: function(data){}
            });
        }
    });
});

在定义class的时候写的是下面这样

class NoticeChange(FlaskForm):
    notice = StringField('', validators=[DataRequired()])
    goods_id = StringField('', validators=[DataRequired()])
    business = StringField('', validators=[DataRequired()])

但是后台的表单验证提示下面这个错:

<UnboundField(StringField, ('',), {'validators': [<wtforms.validators.DataRequired object at 0x0000000004745C18>]})>

这是为什么呀?我先一脸懵逼呀。。。

解决方案

UnboundField 感觉像是后端view没有绑定form吧。
可以提供一下view层的代码吗

这篇关于html - flask button 后台form表单接收 求助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆