使用ajax提交表单,但重定向到另一个页面

使用ajax提交表单,但重定向到另一个页面

问题描述:

如果我想在表单上提交(a)执行某个php文件(url -a),我应该在html和jquery中使用什么? (b)重定向到另一个。(url -b)

What should I use in the html and in the jquery if I want upon form submit to (a) execute a certain php file (url-a); (b) redirect to another one.(url-b)

我目前实现了jquery表单插件。
http://jquery.malsup.com/form/#getting-started

I currently implemented the jquery form plugin. http://jquery.malsup.com/form/#getting-started

如下所示:

步骤a。包括jquery和表单插件脚本;

step a. included jquery and form plugin scripts;

步骤b。在html中,在表单元素中:

step b. in html, in the form element:

      <form action="url-a.php">
          <!--form code inserted here including input elements, etc and submit-->
      </form>

步骤c。在js中,文档就绪

      $('#form').ajaxForm(function() { 
           $.post("url-a.php", {a: a, b: b});
      }); 

是否应更改其中一个网址链接?假设url-a是ajax应该处理的那个,我想重定向到url-b ..

Should one of these url links be changed? assume that url-a is the one the ajax should take care of, and I want to redirect to url-b..

谢谢!

$('#form').ajaxForm(function() { 
  $.post("url-a.php", {a: a, b: b});
  window.location.href="/url-b.php";
});