【问题标题】:Without Ajax Reload WebPage on Form Submit表单提交时没有 Ajax 重新加载网页
【发布时间】:2016-02-03 04:42:47
【问题描述】:

我有一个包含 HTML 表单的引导模式。现在在表单的提交按钮单击事件上,我需要重新加载(刷新)网页。我没有使用 Ajax,我的服务器端代码是从表单的表单 Action 方法调用的。如何重新加载网页,在这种情况下?..这是我的 HTML ..

<div class="modal fade" id="StudentModal" tabindex="-1" role="dialog" aria-labelledby="StudentModalLabel" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content">
 <form action="~/GetStudent" class="form-horizontal" role="form" method="post" id="frmStudent">
    <div class="modal-footer">
       <div class="pull-right">
          <button type="submit" class="btn btn-success" id="save" data-dismiss="modal"><i class="glyphicon glyphicon-ok"></i> Save</button>
          <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i> Close</button>
       </div>
    </div>
 </form>

这是我的提交按钮点击事件..

$('#save').on('click', function () {
  $("#frmStudent").submit();
});

请帮我完成它..谢谢..

【问题讨论】:

  • 首先,这里不需要点击处理程序,因为type='submit' 会为您完成。要重新加载页面,请在服务器端表单处理完成后将用户重定向到该页面!
  • @RayonDabre 如果没有 Click 处理程序,我的模态表单不会关闭..
  • 您的意思是没有提交表单?这不应该发生,除非有一些脚本阻止它。
  • @RayonDabre 表单正在提交,但 Bootstrap 模式没有关闭
  • 您可以使用elem.modal('hide'); 关闭modal,但在提交表单时,关闭模式没有意义..

标签: javascript jquery html forms


【解决方案1】:

试试这个:

$('#frmStudent').submit(function () {

  // Do your stuff here (on form Submit)

});

【讨论】:

    猜你喜欢
    • 2017-06-22
    • 2023-04-01
    • 2018-04-10
    • 1970-01-01
    • 1970-01-01
    • 2019-11-26
    • 1970-01-01
    • 2012-08-06
    • 2013-11-19
    相关资源
    最近更新 更多