温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么解决jquery submit不提交问题

发布时间:2021-11-11 10:09:16 来源:亿速云 阅读:107 作者:iii 栏目:web开发

这篇文章主要讲解了“怎么解决jquery submit不提交问题”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么解决jquery submit不提交问题”吧!

jquery submit不提交的解决办法:1、打开相应的表单代码文件;2、将button的type改为submit;3、修改按钮id即可。

怎么解决jquery submit不提交问题

本文操作环境:windows7系统、jquery3.2.1版、DELL G3电脑

jquery submit 不提交怎么办?

jquery submit()不能提交表单的解决方法

今天写表单提交的时候需要增加一个确认提示,所以没有使用submit按钮提交,改用jq的submit(),然后问题了

<form class="form-horizontal m-t" method="post" action="@Url.Action("Edit")" id="form">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h6>添加</h6>
                    </div>
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">开始时间:</label>
                            <div class="col-sm-8">
                                <span>
                                    @(Model.annualRate_beginDate?.ToString("yyyy-MM-dd"))
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">结束时间:</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="annualRate_endDate" id="annualRate_endDate" onclick="laydate({ istime: false, format: 'YYYY-MM-DD' })" value="@Model.annualRate_endDate.ToString("yyyy-MM-dd")" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">年利息%:</label>
                            <div class="col-sm-8">
                                <input type="number" step="0.01" class="form-control" id="annualRate_rate" name="annualRate_rate" value="@Model.annualRate_rate.ToString("#0.00")" required>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-lg btn-primary" id="submit_btn" type="button">
                                    提交
                                </button>
                                <a class="btn btn-lg btn-white" href="@Url.Action("Index")">
                                    取消
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
 1 <script type="text/javascript">
 2     $(function () {
 3         $("#submit").click(function () {
 4             var start = '@(Model.annualRate_beginDate?.ToString("yyyy-MM-dd"))';
 5             var end = $("#annualRate_endDate").val();
 6             var val = $("#annualRate_rate").val();
 7             layer.confirm('请确认所填写的信息是否正确?<br/>开始时间:' + start + '<br/>结束时间:' + end + '<br/>年利率:' + val, { icon: 3, title: '提示' }, function (index) {
 8                 $("#form").submit();
 9                 layer.close(index);
10             });
11         });
12     })
13 </script>

点击提交按钮出现确认提示,但是确认后就没反应了

但是将button的type改为submit却又能提交

于是上jQuery API查找原因,看到以下这段文字顿时明白了:

Additional Notes:
Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.

大概意思是表单和其子元素不宜用一个表单的属性的属性作为name或id的名称,如submit, length, 和 method等,否则会产生冲突,名称冲突可能就会导致这种情况。

原来是因为按钮id设为了submit

接下来只要将id改了就没问题了

感谢各位的阅读,以上就是“怎么解决jquery submit不提交问题”的内容了,经过本文的学习后,相信大家对怎么解决jquery submit不提交问题这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI