如何在Django中禁用html按钮?

2024-06-01 01:48:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python和django的初学者。在

我想禁用HTML“注册”按钮。一旦“插件注册成功,”将出现此消息。在

目前我使用json响应返回消息

return JsonResp(request,message=_('vCenter plugin registered successfully.'),)

这是密码。。在

^{pr2}$

Tags: django插件json消息messagereturnrequesthtml
1条回答
网友
1楼 · 发布于 2024-06-01 01:48:04

一种方法是使用ajax提交表单,然后解析响应,然后基于该响应禁用按钮。在

<script language="JavaScript">
        $(document).ready(function() {
            $('#YOUR_FORM').submit(function() {
                $.ajax({ // create an AJAX call...
                    data: $(this).serialize(), // get the form data
                    type: $(this).attr('method'), // GET or POST
                    url: $(this).attr('action'), // the file to call
                    success: function(response) { // on success..
                        //check the response and disable submit button
                    }
                });
                return false;
            });
        });
    </script>

相关问题 更多 >