form表单提交后ajax异步调用另一个url


... ...
提交
Submit
function submitForm(){ if(_finst_taskComment.value==""){ alert("请填写审批意见"); }else{ document.getElementsByTagName("form")[0].submit(); } }


另一个url如http://........

 function submitForm(){ 
if(_finst_taskComment.value==""){ alert("请填写审批意见"); }
else{ 
document.getElementsByTagName("form")[0].action='xxxxxxxxxxxxxxxxxx';///更改action属性就行
document.getElementsByTagName("form")[0].submit();
} 
} 

DEMO


 <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
 <form method="post" onsubmit="return check(this)">
 name:<input type="text" name="name" /><br />
 pwd:<input type="password" name="pwd" /><input type="submit" value="提交" />
 </form>
 <script>
     function check(f) {
         if (f.name.value == '') { alert('请输入name!'); f.name.focus(); return false; }
         if (f.pwd.value == '') { alert('请输入pwd!'); f.pwd.focus(); return false; }
         $.ajax({ url: '你要提交到的地址', data: $(f).serialize(), type: 'POST', complete: function (xhr) {

             alert('服务器返回内容:' + xhr.responseText);

             if (xhr.responseText == '1') { //你动态页验证成功就输出1就行,其他不需要输出

                 location.href = 'xxxxxxxxxxxxxxx';//要跳转到的地址
             }
         }
         });

         return false;//阻止表单提交
     }
 </script>