• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
攻城狮的世界我不懂——lmky
梦想还是要有的!
博客园    首页    新随笔    联系   管理    订阅  订阅
怎么实现form表单提交后不重新刷新当前页面

怎么实现表单提交后不重新刷新当前页面

 
 
如何实现表单提交后不重新刷新当前页面

<form name='form1' id='form1' action='/xbcw/cw/xx_xx.action' method='post'>

  <input type="button" id="btnSubmit" name="btnSubmit" value="保存" onclick="addKp()" class="Button2" />

  <input type="button" id="btnSubmit" name="btnSubmit" value="下一步" onclick="doAddCwKpSubmit()" class="Button2" />

</form>


当我点击保存提交FORM表单后,如何让当前页面维持不变(即不刷新当前页)?

在FORM表单后添加一个iframe

  <iframe id="rfFrame" name="rfFrame" src="about:blank" style="display:none;"></iframe> 


点保存提交事件里面需要将target改为iframe的名字:

  JS:document.forms[0].target="rfFrame";

JQuery:$("#f2").attr("target","rfFrame");



这样即提交了FORM保存了数据,页面也不会跳转.
posted on 2016-06-20 09:57  limeiky  阅读(41901)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3