我需要提交一个表单,等后台的操作都完成后跳转到一个页面同时刷新右frame;
本来只是写成简单的:
document.getElementById("goSubmit").submit();
parent.rightframe.location.reload()以为就行了;
结果发现js执行的明显比后台快,结果右边刷新后后台还没跑完、、
+++++++本来想用XMLHttpRequset提交的,可是东西多。就用jquery提交。
但即使我的async值为false,它还是后台没执行完就刷新了,请问怎么解决?
这是js代码:
$(document).ready(function(){
$('#goSubmit').click(function(){
$.ajax({
type: "post",
async: false,
cache: false,
success: function(){parent.mainFrame.location.reload();}
});
});
  });
这是带图片的提交按钮
<input id="goSubmit" type="image" src="theme/default/images/confirm.gif" />  
谢谢!

解决方案 »

  1.   

    你的$.ajax里连服务器的端的地址都没有,怎么提交?
      

  2.   


    form 里面是 你点击提交form时候提交的 地址显示你是ajax 提交 ,:
    比方是:click 时候本来是提交from的, 然后你在里面(嵌套提交了ajax,不知道你的click 有没有被吧 from的覆盖)提交了ajax ,这个与form 是没有丝毫关系的,所以 URL 还是要指明
      

  3.   

    现在我把代码写成这样,后台能取到参数,但后台执行完后并没有执行alert("ok"),而是直接显示了我后台printWriter输出的东西,如果不输出则是个空白页面
     <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
          <script type="text/javascript">
         $(document).ready(function(){
    $('#submit').click(function(){
    $.ajax({
    url: "login",
    async: false,
    type: "post",
    success: function(){alert("ok");}
    });
    });
      
      });
          </script>
      </head>
      <body>
      <form action="login" id="form" method="post">
          <input type="text" name="name" id="username" />
          <input type="password" name="password" />
          <input id="submit" type="submit" value="提交" />
      </form>
      

  4.   

    $.ajax使用的地址与Form里的地址是不一样的,要显示的设置