在jquery中使用 submit()方法不能提交表單如何解決?針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
成都創新互聯是一家集網站建設,融水企業網站建設,融水品牌網站建設,網站定制,融水網站建設報價,網絡營銷,網絡優化,融水網站推廣為一體的創新建站企業,幫助傳統企業提升企業形象加強企業競爭力。可充分滿足這一群體相比中小企業更為豐富、高端、多元的互聯網需求。同時我們時刻保持專業、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學習、思考、沉淀、凈化自己,讓我們為更多的企業打造出實用型網站。
jquery是一個簡潔而快速的JavaScript庫,它具有獨特的鏈式語法和短小清晰的多功能接口、高效靈活的css選擇器,并且可對CSS選擇器進行擴展、擁有便捷的插件擴展機制和豐富的插件,是繼Prototype之后又一個優秀的JavaScript代碼庫,能夠用于簡化事件處理、HTML文檔遍歷、Ajax交互和動畫,以便快速開發網站。
<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(" rel="external nofollow" Index")"> 取消 </a> </div> </div> </div> </div> </div> </div> </form>
<script type="text/javascript"> $(function () { $("#submit").click(function () { var start = '@(Model.annualRate_beginDate?.ToString("yyyy-MM-dd"))'; var end = $("#annualRate_endDate").val(); var val = $("#annualRate_rate").val(); layer.confirm('請確認所填寫的信息是否正確?<br/>開始時間:' + start + '<br/>結束時間:' + end + '<br/>年利率:' + val, { icon: 3, title: '提示' }, function (index) { $("#form").submit(); layer.close(index); }); }); }) </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
關于在jquery中使用 submit()方法不能提交表單如何解決問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注創新互聯行業資訊頻道了解更多相關知識。
網站題目:在jquery中使用submit()方法不能提交表單如何解決
文章來源:http://m.2m8n56k.cn/article44/jdchee.html
成都網站建設公司_創新互聯,為您提供做網站、小程序開發、商城網站、營銷型網站建設、微信公眾號、網站收錄
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯